Hi,
I have a Page.RegisterClientScriptBlock in datagrid itemdatabound which
creates dynamic javascript arrays for each row generated. This works fine on
datagrid loads.
But when i did the sort on the datagrid, I see the same javascript arrays in
the pagesource (not the updated ones).
I am calling the databind in the grid sort command too and the Grid looks
good with the sorted items.
For eg:
Datagrid with no Sort:
Disp[0] = 'myname';
Datagrid with Sort:
Disp[0]='mynewsortedname';
But Disp[0] is still holding the old value in the page source.
code:
=====
private void Page_Load(object sender, System.EventArgs e)
{
if (!(IsPostBack))
{}
else
{
SortField = "firstname";
dgresults.DataSource = CreateDataSource();
dgresults.DataBind();
}
}
protected void dgresults_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item
||e.Item.ItemType==ListItemType.AlternatingItem)
{
Page.RegisterClientScriptBlock("ctxmenu"+e.Item.It emIndex.ToString(),ctxmenu.CreateMenu(Convert.ToIn t32(e.Item.ItemIndex),strDisp,strUrl));
}
}
public void dgresults_sort(object sender, DataGridSortCommandEventArgs e)
{
SortField = (string)e.SortExpression;
dgresults.Columns.Clear();
dgresults.DataSource = CreateDataSource();
dgresults.DataBind();
}
Thanks
Gane