This is a migrated thread and some comments may be shown as answers.

RadGrid Rebind can't access C# globals in callback

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Seth
Top achievements
Rank 1
Seth asked on 04 Oct 2011, 10:49 PM
I have a RadGrid that loads from a DataTable pulled from my database.  The user can click a "Refresh" button on the page that will update the database behind the scenes, then update various labels on the page as well as the RadGrid from the new database entries, all through RadAjax.  The labels correctly update, but the problem comes when I call RadGrid1.Rebind();

The "Refresh" click code sets two global variables in the codebehind and then uses those values in updating the page.  Then Rebind() gets called at the end of the function, and in the process, processes each row of the grid.  One column in each row calls a function that uses one of the global variabes set earlier to genereate an image URL.  However, even though the same global variable was accessible in the Callback code, in the Rebind code it is suddenly NULL.  I get a Javascript error and the RadGrid doesn't get updated.

Summary: How do I set variables in my RadAjax callback function that will be accessable by the functions Rebind calls when repopulating my RadGrid?

Thanks in advance for your help.

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 07 Oct 2011, 07:32 AM
Hello Seth,

When using an asynchronous postback using AJAX, the page goes through its regular life cycle. In this respect, there is no difference in functioning of the page in an AJAX or regular postback. A class-level variable you set in one method should be available in all methods in the scope of the  current postback. To verify if this issue is AJAX-related, consider disabling all AJAX functionalitty from your page and see if the same scenario can be reproduced.

Veli
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Seth
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or