1. User clicks the edit link on a row
2. User clicks delete on a different row while the edit row is still open
3. User clicks Add new and recieves the message "you may only have one item open at a time"
The issue seems to be that the radgrids editindexes.count is still at one when the user clicks delete even though the row in edit mode visually closes.
I am handling the deletecommand but all I am doing is reading in the id to delete from e.commandargument and deleting it.
Is there something I need to do in the deletecommand to get the editindexes to reload?
The simple solution would be to not let the user delete, but there has to be another solution...
Protected Sub rg_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rg.ItemCommand
lblMessage.Text = ""
If (e.CommandName = RadGrid.InitInsertCommandName) Then
If ((CType(source, RadGrid).EditIndexes.Count > 0) _
OrElse e.Item.OwnerTableView.IsItemInserted) Then
prjUtilities.showFeedback(lblMessage, "*You may only have one item open at a time", True)
e.Canceled = True
cblExpenses.Enabled = False
Else
e.Canceled = True
Dim off As New offType
e.Item.OwnerTableView.InsertItem(off)
'Hides the edit column when in create mode
Dim editColumn As GridEditCommandColumn = CType(CType(source, RadGrid).MasterTableView.GetColumn("edit"), GridEditCommandColumn)
editColumn.Visible = False
cblExpenses.Enabled = False
End If
ElseIf e.CommandName = "PerformInsert" Then
Dim editColumn As GridEditCommandColumn = CType(CType(source, RadGrid).MasterTableView.GetColumn("edit"), GridEditCommandColumn)
If Not editColumn.Visible Then
editColumn.Visible = True
End If
cblExpenses.Enabled = True
ElseIf e.CommandName = "Cancel" Then
cblExpenses.Enabled = True
prjUtilities.showFeedback(lblMessage, "Changes Cancelled", False)
Dim editColumn As GridEditCommandColumn = CType(CType(source, RadGrid).MasterTableView.GetColumn("edit"), GridEditCommandColumn)
If Not editColumn.Visible Then
editColumn.Visible = True
End If
Else
'reset the edit column to visible
cblExpenses.Enabled = False
Dim editColumn As GridEditCommandColumn = CType(CType(source, RadGrid).MasterTableView.GetColumn("edit"), GridEditCommandColumn)
If Not editColumn.Visible Then
editColumn.Visible = True
End If
End If
End Sub
<telerik:RadGrid ID="rg" runat="server" AllowPaging="True" AutoGenerateColumns="False"
GridLines="None" Skin="Office2007">
<HeaderContextMenu>
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
</HeaderContextMenu>
<MasterTableView CommandItemDisplay="Top">
<CommandItemTemplate>
<table>
<tr>
<td width="30%">
<asp:ImageButton ID="btnAddImbtn" runat="server" CommandName="InitInsert" CausesValidation="false"
ImageUrl="~/images/RadControls Skins/Office2007/Grid/AddRecord.gif" />
<asp:LinkButton ID="btnAddlkbtn" runat="server" Font-Bold="true" CausesValidation="false"
CommandName="InitInsert">Click Here to Add New</asp:LinkButton>
</td>
<td width="40%">
</td>
<td width="30%">
</td>
</tr>
</table>
</CommandItemTemplate>
<EditFormSettings EditFormType="WebUserControl" UserControlName="~/UserControls/ucOff.ascx" />
<Columns>
<telerik:GridEditCommandColumn EditText="Edit" UniqueName="edit" />
<telerik:GridBoundColumn DataField="offid" UniqueName="offid"
HeaderText="offid" Visible="false">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn UniqueName="del">
<ItemTemplate>
<asp:LinkButton ID="lblDelete" runat="server" Text="Delete" CommandName="Delete"
CommandArgument='<%#Eval("offid")%>' CausesValidation="false" OnClientClick="return confirm('Are you sure you want to delete this record?');"></asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>