Issues rebinding data to RadGrid

1 posts, 0 answers
  1. Kyle
    Kyle avatar
    6 posts
    Member since:
    Dec 2012

    Posted 01 Jan 2013 Link to this post

    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?
               
Back to Top