I have a grid with an form template for editing and adding. The grid also has a deletebutton column to delete rows. All the events are firing but the grid doesn't refresh after itemcommand completes its work after an insert, update or delete is performed on the database. I've stepped through the code and rebind() is being called. We bind to a list of objects.
This is the behavior I'm experiencing
Clicking Add
The edit form opens, I enter the data and press Save. The data saves, the form does not close. I then click Cancel, the form closes and the grid refreshes without a full postback,
Clicking the Edit icon in the row
The edit form opens, I modify the data and press Save. The data saves, the form does close (but only because I included Me.rgAccountGroupAuthorizations.MasterTableView.ClearEditItems() The grid does not refresh. If I click Cancel the form closes and the grid doesn't refresh.
Clicking the Delete icon in the row
After confirmation, the data is deleted but the grid doesn’t refresh.
I've isolated the code on its own page. The page doesn't have any ajax proxy (we use master pages) We would really prefer to use the form template feature rather than a custom edit page or user control.
Here is the markup and codebehind
​
This is the behavior I'm experiencing
Clicking Add
The edit form opens, I enter the data and press Save. The data saves, the form does not close. I then click Cancel, the form closes and the grid refreshes without a full postback,
Clicking the Edit icon in the row
The edit form opens, I modify the data and press Save. The data saves, the form does close (but only because I included Me.rgAccountGroupAuthorizations.MasterTableView.ClearEditItems() The grid does not refresh. If I click Cancel the form closes and the grid doesn't refresh.
Clicking the Delete icon in the row
After confirmation, the data is deleted but the grid doesn’t refresh.
I've isolated the code on its own page. The page doesn't have any ajax proxy (we use master pages) We would really prefer to use the form template feature rather than a custom edit page or user control.
Here is the markup and codebehind
<telerik:RadGrid ID="rgAccountGroupAuthorizations" OnNeedDataSource="rgAccountGroupAuthorizations_NeedDataSource" OnItemDataBound="rgAccountGroupAuthorizations_ItemDataBound" OnItemCommand="rgAccountGroupAuthorizations_ItemCommand" Width="600" Height="100%" AllowFilteringByColumn="false" AllowPaging="false" AllowSorting="true" AutoGenerateColumns="false" Skin="Web20" ShowHeader="true" ShowFooter="false" CellSpacing="0" GridLines="Both" BorderWidth="0" EnableViewState="false" runat="server" > <ClientSettings Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="true" EnableRowHoverStyle="true"> </ClientSettings> <MasterTableView TableLayout="Fixed" DataKeyNames="AuthorizationGroupID,OrganizationID" ClientDataKeyNames="AuthorizationGroupID,OrganizationID" CommandItemDisplay="Top" AllowMultiColumnSorting="false" AllowNaturalSort="false" EnableViewState="true"> <CommandItemTemplate> <div style="height: 30px; margin-left: 10px;"> <div style="float: left;"> <asp:LinkButton ID="btnInserAuthorizationGroup" CommandName="initinsert" font-size="Larger" Font-Bold="true" runat="server" ><img style="border:0px;vertical-align:middle;" alt="" src="../Images/add.gif" /><span style="padding-left: 10px; padding-top: 20px;">Add New Permission Group</span></asp:LinkButton> </div> </div> </CommandItemTemplate> <EditFormSettings EditFormType="Template"> <FormTemplate> <table id="Table2" class="baseTable"> <tr> <td class="col1"> <asp:Label AssociatedControlID="txtAuthorizationGroup" Text="Permission Group" runat="server" /><uc:rfm runat="server" /> </td> <td> <telerik:RadTextBox ID="txtAuthorizationGroup" Width="300" MaxLength="100" runat="server" /> <asp:RequiredFieldValidator ID="rfvtxtAuthorizationGroup" ControlToValidate="txtAuthorizationGroup" EnableClientScript="true" Display="Dynamic" ValidationGroup="AuthorizationGroup" ForeColor="red" ErrorMessage="Required" runat="server" /> </td> </tr> <tr class="footer"> <td colspan="2"> <telerik:RadButton ID="btnSaveAuthorizationGroup" Text="Save Permission Group" CommandName="InsertAuthorizationGroup" ValidationGroup="AuthorizationGroup" runat="server" /> <telerik:RadButton ID="btnSaveAuthorizationGorupCancel" Text="Cancel" CommandName="cancel" runat="server" /> </td> </tr> </table> </FormTemplate> </EditFormSettings> <SortExpressions> <telerik:GridSortExpression FieldName="AuthorizationGroup" SortOrder="Ascending" /> </SortExpressions> <Columns> <telerik:GridBoundColumn DataField="AuthorizationGroup" HeaderText="Permission Group Description" SortExpression="SortName" HeaderStyle-Font-Size="Larger" HeaderStyle-Width="180px" HeaderStyle-Font-Bold="true" ItemStyle-Font-Bold="true" ItemStyle-Font-Size="Larger"> </telerik:GridBoundColumn> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditButton" EditImageUrl="../Images/edit.gif" HeaderText="Edit"> <HeaderStyle HorizontalAlign="Center" ForeColor="#000000" Font-Bold="true" Width="50px" /> <ItemStyle HorizontalAlign="Center" ForeColor="#000000" Font-Bold="true" Width="50px" /> </telerik:GridEditCommandColumn> <telerik:GridButtonColumn ConfirmText="Delete this Permission Group?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" ConfirmDialogHeight="160px" ConfirmDialogWidth="250px" UniqueName="DeleteButton" ImageUrl="../Images/delete.gif" HeaderText="Delete" > <HeaderStyle HorizontalAlign="Center" ForeColor="#000000" Font-Bold="true" Width="50px" /> <ItemStyle HorizontalAlign="Center" ForeColor="#000000" Font-Bold="true" Width="50px" /> </telerik:GridButtonColumn> </Columns> </MasterTableView></telerik:RadGrid>Protected Sub rgAccountGroupAuthorizations_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs) Me.rgAccountGroupAuthorizations.DataSource = AuthorizationGroupManager.GetListOfAuthorizationGroupsByOrganizationID(Convert.ToInt32(Me.hidOrganizationID.Value))End SubProtected Sub rgAccountGroupAuthorizations_ItemDataBound(sender As Object, e As GridItemEventArgs) Select Case True Case TypeOf e.Item Is GridEditFormInsertItem Case TypeOf e.Item Is GridEditFormItem Dim GridEditFormItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem) If GridEditFormItem.IsInEditMode Then Using AuthorizationGroup As AuthorizationGroup = DirectCast(GridEditFormItem.DataItem, AuthorizationGroup) Dim txt As RadTextBox = DirectCast(GridEditFormItem.FindControl("txtAuthorizationGroup"), RadTextBox) txt.Text = AuthorizationGroup.AuthorizationGroup End Using DirectCast(GridEditFormItem.FindControl("btnSaveAuthorizationGroup"), RadButton).Text = "Update Permission Group" DirectCast(GridEditFormItem.FindControl("btnSaveAuthorizationGroup"), RadButton).CommandName = "updateauthorizationgroup" End If Case TypeOf e.Item Is GridDataItem Dim GridDataItem As GridDataItem = DirectCast(e.Item, GridDataItem) Dim AuthorizationGroupID As Int32 = Convert.ToInt32(GridDataItem.GetDataKeyValue("AuthorizationGroupID")) Dim imgbtn As ImageButton imgbtn = DirectCast(GridDataItem.FindControl("EditButton"), ImageButton) If imgbtn IsNot Nothing Then End If imgbtn = DirectCast(GridDataItem.FindControl("gbcDeleteButton"), ImageButton) If imgbtn IsNot Nothing Then imgbtn.CommandArgument = AuthorizationGroupID.ToString() End If Case TypeOf e.Item Is GridCommandItem Dim GridCommandItem As GridCommandItem = DirectCast(e.Item, GridCommandItem) Dim lnkb As LinkButton lnkb = DirectCast(GridCommandItem.FindControl("btnInserAuthorizationGroup"), LinkButton) If lnkb IsNot Nothing Then End If End SelectEnd SubProtected Sub rgAccountGroupAuthorizations_ItemCommand(sender As Object, e As GridCommandEventArgs) If TypeOf e Is GridCommandEventArgs And e.CommandName.ToLower = "delete" Then Dim GridDataItem As GridDataItem = DirectCast(e.Item, GridDataItem) Using AuthorizationGroup As AuthorizationGroup = AuthorizationGroupManager.GetAuthorizationGroup(DirectCast(GridDataItem.DataItem, AuthorizationGroup).AuthorizationGroupID) AuthorizationGroupManager.Delete(AuthorizationGroup) Me.rgAccountGroupAuthorizations.Rebind() End Using Me.rgAccountGroupAuthorizations.Rebind() ElseIf TypeOf e.Item Is GridEditableItem Then Dim GridEditableItem As GridEditableItem = DirectCast(e.Item, GridEditableItem) If Not GridEditableItem.IsInEditMode And e.CommandName.ToLower = "updateauthorizationgroup" Then Dim GridDataItem As GridDataItem = DirectCast(e.Item, GridDataItem) Dim AuthorizationGroupID As Int32 = Convert.ToInt32(GridDataItem.GetDataKeyValue("AuthorizationGroupID")) Dim txt As RadTextBox = DirectCast(GridDataItem.EditFormItem.FindControl("txtAuthorizationGroup"), RadTextBox) Using AuthorizationGroup As AuthorizationGroup = AuthorizationGroupManager.GetAuthorizationGroup(AuthorizationGroupID) AuthorizationGroup.AuthorizationGroup = txt.Text AuthorizationGroupManager.Update(AuthorizationGroup) End Using txt.Text = "" Me.rgAccountGroupAuthorizations.MasterTableView.ClearEditItems() Me.rgAccountGroupAuthorizations.Rebind() ElseIf GridEditableItem.IsInEditMode And e.CommandName.ToLower = "insertauthorizationgroup" Then Dim GridEditFormInsertItem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem) Dim x As String = "" Dim txt As RadTextBox = DirectCast(GridEditFormInsertItem.FindControl("txtAuthorizationGroup"), RadTextBox) Using AuthorizationGroup As New AuthorizationGroup() AuthorizationGroup.OrganizationID = Convert.ToInt32(Me.hidOrganizationID.Value) AuthorizationGroup.AuthorizationGroup = txt.Text AuthorizationGroupManager.Insert(AuthorizationGroup) End Using txt.Text = "" Me.rgAccountGroupAuthorizations.MasterTableView.ClearEditItems() Me.rgAccountGroupAuthorizations.Rebind() End If End IfEnd Sub​
