In my grid I have a GridButton column with a commandname =Delete
I also have ondeletecommand=RadGridName_deleteCommand
When I click the delete button, the row is deleted, but the code in the deletecommand handler never gets executed, so how is the row deleted ? Why is the deletecommand event handler never executed. Heres the grid code
and heres the event handler in the codebehind. Ive set a breakpoint on the firstline, but its never reached
Can anyone see whats going on here ?
I also have ondeletecommand=RadGridName_deleteCommand
When I click the delete button, the row is deleted, but the code in the deletecommand handler never gets executed, so how is the row deleted ? Why is the deletecommand event handler never executed. Heres the grid code
<telerik:RadGrid ID="RadGridImages" runat="server" GridLines="None" |
OnItemDataBound="RadGridImages_ItemDataBound" onneeddatasource="RadGridImages_NeedDataSource" |
AllowPaging="True" PageSize="5" Skin="Vista" Width="750px" AllowSorting="True" |
BorderStyle="None" |
ShowStatusBar="True" ondeletecommand="RadGridImages_DeleteCommand"> |
<MasterTableView AutoGenerateColumns="False" DataKeyNames="ImageID"> |
<Columns> |
<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName= "DeleteColumn" ConfirmText="Are you sure ?"/> |
<telerik:GridBoundColumn DataField="ImageID" HeaderText="Image ID" SortExpression="ImageID" |
UniqueName="ImageID" Visible="false"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="ArtistID" HeaderText="Artist ID" SortExpression="ArtistID" |
UniqueName="ArtistID" Visible="false"> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn DataField="ImageThumbURL" UniqueName="ImageThumbURLColumn" HeaderText="Artist"> |
<ItemTemplate> |
<asp:Image ID="ImageThumbNail" runat="server"></asp:Image> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridBoundColumn DataField="ImageDisplayFilename" HeaderText="Image" SortExpression="ImageDisplayFilename" |
UniqueName="ImageDisplayFilename" DataFormatString="<nobr>{0}</nobr>"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="ImageThumbURL" HeaderText="ImageThumbURL" SortExpression="ImageThumbURL" |
UniqueName="ImageThumbURL" Visible="False"> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn DataField="IsPrimaryImage" UniqueName="IsPrimaryImage" HeaderText="Primary Image ?"> |
<ItemTemplate> |
<asp:Label ID="LabelPrimary" runat="server" Text="Label"></asp:Label> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
</Columns> |
<RowIndicatorColumn Visible="False"> |
<HeaderStyle Width="20px" /> |
</RowIndicatorColumn> |
<ExpandCollapseColumn Resizable="False" Visible="False"> |
<HeaderStyle Width="20px" /> |
</ExpandCollapseColumn> |
<EditFormSettings> |
<PopUpSettings ScrollBars="None" /> |
</EditFormSettings> |
</MasterTableView> |
<PagerStyle Mode="NextPrevAndNumeric" /> |
<FilterMenu Skin="Vista" EnableTheming="True"> |
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
</FilterMenu> |
</telerik:RadGrid> |
protected void RadGridImages_DeleteCommand(object source, GridCommandEventArgs e) |
{ |
GridDataItem item = (GridDataItem)e.Item; |
//Get the primary key value using the DataKeyValue. |
Int32 id = -1; |
string res = string.Empty; |
bool ok = Int32.TryParse(item.OwnerTableView.DataKeyValues[item.ItemIndex]["ImageID"].ToString(), out id); |
if (ok) |
{ |
res = imagemanager.DeleteImage(id); |
if (!string.IsNullOrEmpty(res)) |
{ |
RadGridImages.Controls.Add(new LiteralControl("Unable to delete image. Reason: " + res)); |
e.Canceled = true; |
} |
} |
} |