RegisterClientScriptBlock not updating

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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.ItemIndex.ToString(),ctxmenu.CreateMenu(Convert.ToInt32(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


.



Relevant Pages

  • RE: Datagrid paging I lose my sort
    ... Microsoft Online Support ... if there're any other postback events where we need to rebind the ... | DataGrid, we also need to specify the correct Sort Expression for the ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • RE: Datagrid paging I lose my sort
    ... if there're any other postback events where we need to rebind the ... DataGrid, we also need to specify the correct Sort Expression for the ... Datagrid paging I lose my sort ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • RE: Datagrid paging I lose my sort
    ... you've also provide paging and sorting ... function for the datagrid. ... currently you found that after sorting ... So when we first make a sort operation, ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: HELP-Sorted Datagrids and modal dialogs
    ... So if you have a column lastname, and under the original sort, Ryan ... I have a form with a datagrid that can be sorted or unsorted ... > I believe it has something to do what I am setting CurrencyManager ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: HELP-Sorted Datagrids and modal dialogs
    ... So if you have a column lastname, and under the original sort, Ryan ... I have a form with a datagrid that can be sorted or unsorted ... > I believe it has something to do what I am setting CurrencyManager ...
    (microsoft.public.dotnet.framework)