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

Ajax for telerik radgrid

1 Answer 26 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
2d
Top achievements
Rank 1
2d asked on 24 Oct 2013, 07:04 PM

I have a telerik radgrid along with several gridbound columns. I want to reload the grid with the new data on a button click (which deletes one of the rows) without doing a posting back and refreshing the page.

But I am not sure how to use the telerik ajax manager, I have it as follow:

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

then, I have a LinkButton when onclick it fires the btn_OnCommand on server side, which rebinds myGrid with the new retrieved data. But I won't see the changes on client unless I refresh the page. Could someone point me how to use the ajax manager?

Thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 25 Oct 2013, 07:57 AM
Hi 2d,

I guess you want to reload the Grid with new data on the click event of external RadLinkButton. RadAjaxManager is used for refreshing the Grid without doing complete page postback. Please have a look into the code snippet I tried.

ASPX:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadButton1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
    <MasterTableView DataSourceID="SqlDataSource1">
        <Columns>
            <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32" FilterControlAltText="Filter OrderID column"
                HeaderText="OrderID" SortExpression="OrderID" UniqueName="OrderID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="CustomerID" FilterControlAltText="Filter CustomerID column"
                HeaderText="CustomerID" SortExpression="CustomerID" UniqueName="CustomerID">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
<telerik:RadButton ID="RadButton1" runat="server" Text="Delete Row" ButtonType="LinkButton"
    OnClick="RadButton1_Click">
</telerik:RadButton>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    SelectCommand="SELECT top 10 [OrderID], [CustomerID] FROM [Orders]">
</asp:SqlDataSource>

C#:
protected void RadButton1_Click(object sender, EventArgs e)
{
    SqlDataSource1.SelectCommand = "SELECT top 9 [OrderID], [CustomerID] FROM [Orders]";
    RadGrid1.DataBind();
}

Thanks,
Princy.
Tags
Ajax
Asked by
2d
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or