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

Ajax problem in RadGrid Delete

1 Answer 20 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Justin Maslow
Top achievements
Rank 1
Justin Maslow asked on 11 Sep 2013, 03:31 PM

I have the following markup on my aspx page:

<
telerik:RadAjaxManagerProxy runat="server" ID="MyAjaxManagerProxy">
       <AjaxSettings>
           <telerik:AjaxSetting AjaxControlID="MyRadGrid1">
               <UpdatedControls>
                   <telerik:AjaxUpdatedControl ControlID="MyRadGrid1" LoadingPanelID="AjaxLoadingPanel1" />
               </UpdatedControls>
           </telerik:AjaxSetting>
       </AjaxSettings>
   </telerik:RadAjaxManagerProxy>
   <telerik:RadAjaxLoadingPanel ID="AjaxLoadingPanel1" runat="server" Transparency="20">
       <telerik:RadCodeBlock ID="VpLaborHourlyRadCodeBlock1" runat="server">
           <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
               style="border: 0;" />
       </telerik:RadCodeBlock>
   </telerik:RadAjaxLoadingPanel>

My radgrid declaration immediately follows.

I have a delete button in each row of my radgrid. The delete event handler is implemented in ItemCommand as so:

protected void MyRadGrid_ItemCommand(object sender, GridCommandEventArgs e)
   {
     if (e.CommandName == RadGrid.InitInsertCommandName)
     {
      // Save the row into database.
     }
     else if (e.CommandName == RadGrid.DeleteCommandName)
     {
      // Delete the row from the database.
     }
   }
The delete function works fine, that is, the row does get deleted from the database.  There is only one problem as described below.

The first time I delete a row, ajax works perfectly, no full postback, the grid stays where it is and get rebound nicely after delete completes.

The second time I delete a row, it still successfully deletes the row from the database, but it does a full postback, and the entire page reloads, totally without the nice ajax feature.

What's wrong? Any hint please?









1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 13 Sep 2013, 06:08 AM
Hi Justin,

 I'm not sure what may be causing the issue,the code works fine at my end,can you provide your full code snippet.Below is a sample i have tried with a UserControl.

ASPX:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
<uc1:webusercontrol id="WebUserControl1" runat="server"></uc1:webusercontrol>

ASCX:
<telerik:RadAjaxManagerProxy ID="AjaxManagerProxy1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
<telerik:RadGrid ID="RadGrid1" runat="server">
    <MasterTableView DataKeyNames="OrderID">
        <Columns>
            <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID" />
            <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" UniqueName="ShipCity" />
            <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete">
            </telerik:GridButtonColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>


Thanks,
Princy
Tags
Grid
Asked by
Justin Maslow
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or