Is there any way to delete a record server side from a control outside of the RadGrid and have the grid update when the postback returns?
I have a LinkButton that handles deleting a record from the datasource and then calls the RadGrid Rebind method.
This triggers the NeedDataSource() method to fire and subsequently the RadGrid PreRender. The problem is that when the page finishes the postback, the deleted row is still visible in the grid. Any other interaction with the grid such as selecting a row or sorting, calls NeedDataSource again and the deleted row is gone.
I've verified that the data that comes back to NeedDataSource right after delete does not contain the row that was deleted.
There is a similar "Add" functionality that works fine. Meaning the row is added, data updated and Rebind called and grid shows the new row. I presume this is because the add calls a RadWindow that is still within the RadPanel that contains the RadGrid whereas the Delete button is outside of the Panel.
Here is the psuedo code of what I'm doing.
Private Sub ibtnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ibtnDelete.Click
DeleteRecord()
End Sub
Private Sub DeleteRecord()
DeleteLogicHere()
UpdateDataSourceHere()
RadGrid1.Rebind()
End Sub
Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
RadGrid1.DataSource = FetchDataSourceHere()
End Sub
Here is a mockup of the aspx side.
<
asp:LinkButton
ID
=
"ibtnDelete"
CssClass
=
"icon delete"
TabIndex
=
"10"
runat
=
"server"
ToolTip
=
"Delete Current Record"
ClientClick
=
"return confirm('Are you sure you want to delete this record? If yes, click OK.');"
></
asp:LinkButton
>
<
telerik:RadAjaxPanel
runat
=
"server"
ID
=
"RadAjaxPanel1"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
CssClass
=
"controlsWrapper"
>
<
telerik:RadGrid
RenderMode
=
"Lightweight"
runat
=
"server"
ID
=
"RadGrid1"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
AllowPaging
=
"True"
AllowSorting
=
"true"
AutoGenerateColumns
=
"false"
OnSelectedIndexChanged
=
"RadGrid1_SelectedIndexChanged"
OnPreRender
=
"RadGrid1_PreRender"
OnSortCommand
=
"RadGrid1_SortCommand"
OnPageIndexChanged
=
"RadGrid1_PageIndexChanged"
OnPageSizeChanged
=
"RadGrid1_PageSizeChanged"
>
</
telerik:RadGrid
>
</
telerik:RadAjaxPanel
>
I have also tried adding ibtnDelete to the RadAjaxManager with the RadGrid, but that did not resolve anything.