I create
<CommandItemTemplate>
<table width="100%">
<tr>
<td>
<asp:LinkButton ID="btnAdd"
Text="Add New Content of Course" CommandName="InitInsert" Runat="server"></asp:LinkButton>
</td>
<td>
<asp:LinkButton ID="btnDelete"
Text="Delete Content" CommandName="Delete" Runat="server"></asp:LinkButton>
</td>
<td>
<asp:LinkButton ID="btnRefresh" Text="Refresh data"
CommandName="Rebind" Runat="server"></asp:LinkButton>
</td>
</tr>
</table>
</CommandItemTemplate>
and When I delete item i show error Unable to cast object of type Telerik.Web.UI.GridCommandItem to type 'Telerik.Web.UI.GridEditableItem . I dont know what happen. This is Code i delete item in event delete command
protected void rgTrCategory_DeleteCommand(object source, GridCommandEventArgs e)
{
bool result = false;
try
{
if (e.CommandName == RadGrid.DeleteCommandName)
{
if ("TrContents".Equals(e.Item.OwnerTableView.Name))
{
for (int i = 0; i < e.Item.OwnerTableView.Items.Count; i++)
{
GridDataItem row = e.Item.OwnerTableView.Items[i];
if (row.Selected == true)
{
Image _imgContent = (Image)row.FindControl("imgContent");
if (_imgContent != null)
{
if (File.Exists(Server.MapPath(_imgContent.ImageUrl.Trim())))
{
File.Delete(Server.MapPath(_imgContent.ImageUrl.Trim()));
}
TrAccess.DeleteTrainingContent(row.GetDataKeyValue("f_ConCode").ToString());
result = true;
}
}
}
if (result == true)
{
ShowErrorFunction.ShowError(this.Page, "Delete Successul!");
}
else
{
ShowErrorFunction.ShowError(this.Page, "Please select row to delete");
}
}
}
}
catch
{
}
}
Please help me to solve this problem as impossible as. Thanks alot.
<CommandItemTemplate>
<table width="100%">
<tr>
<td>
<asp:LinkButton ID="btnAdd"
Text="Add New Content of Course" CommandName="InitInsert" Runat="server"></asp:LinkButton>
</td>
<td>
<asp:LinkButton ID="btnDelete"
Text="Delete Content" CommandName="Delete" Runat="server"></asp:LinkButton>
</td>
<td>
<asp:LinkButton ID="btnRefresh" Text="Refresh data"
CommandName="Rebind" Runat="server"></asp:LinkButton>
</td>
</tr>
</table>
</CommandItemTemplate>
and When I delete item i show error Unable to cast object of type Telerik.Web.UI.GridCommandItem to type 'Telerik.Web.UI.GridEditableItem . I dont know what happen. This is Code i delete item in event delete command
protected void rgTrCategory_DeleteCommand(object source, GridCommandEventArgs e)
{
bool result = false;
try
{
if (e.CommandName == RadGrid.DeleteCommandName)
{
if ("TrContents".Equals(e.Item.OwnerTableView.Name))
{
for (int i = 0; i < e.Item.OwnerTableView.Items.Count; i++)
{
GridDataItem row = e.Item.OwnerTableView.Items[i];
if (row.Selected == true)
{
Image _imgContent = (Image)row.FindControl("imgContent");
if (_imgContent != null)
{
if (File.Exists(Server.MapPath(_imgContent.ImageUrl.Trim())))
{
File.Delete(Server.MapPath(_imgContent.ImageUrl.Trim()));
}
TrAccess.DeleteTrainingContent(row.GetDataKeyValue("f_ConCode").ToString());
result = true;
}
}
}
if (result == true)
{
ShowErrorFunction.ShowError(this.Page, "Delete Successul!");
}
else
{
ShowErrorFunction.ShowError(this.Page, "Please select row to delete");
}
}
}
}
catch
{
}
}
Please help me to solve this problem as impossible as. Thanks alot.