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

Issues rebinding data to RadGrid

0 Answers 48 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Kyle
Top achievements
Rank 1
Kyle asked on 02 Jan 2013, 05:01 AM

This is how I set up my AjaxManager:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>


I also have this at the top of my page:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                var ajaxManager;
                function pageLoad()
                {
                    ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");               
                }
    
                function refreshGrid(arg) {
                    if (ajaxManager != null) {
                        ajaxManager.ajaxRequest(arg);
                    }
                    else
                        alert('no element');
                 }                
            </script>
        </telerik:RadCodeBlock>

In the code behind I am getting the data to the control the first time using the Need Data Source. It is pulling from an object that generates xml which I convert to a datatset.

XmlDocument response = request.Send();
XmlReader xmlReader = new XmlNodeReader(response.SelectSingleNode("response/content/readbyquery/collection"));
dsCatalog.ReadXml(xmlReader);
RadGrid1.DataSource = dsCatalog;

This seems to work fine. The data is populated. I have a treelist and a radgrid on the page. Both are generated just fine. I set the tree list to use a javascript function when you click on the element which calls refreshGrid with an ID.

The refresh calls the function in the code behind, which pulls down my xml again with different results but the data is never updated in the RadGrid.

protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
...
XmlDocument response = request.Send();
XmlReader xmlReader = new XmlNodeReader(response.SelectSingleNode("response/content/readbyquery/collection"));
dsCatalog.ReadXml(xmlReader);
RadGrid1.Rebind();
}

Does the rebinding only work with the same dataset? Can it be completely different? Do you see anything in my code that would cause the data not to change?
           

No answers yet. Maybe you can help?

Tags
Ajax
Asked by
Kyle
Top achievements
Rank 1
Share this question
or