【发布时间】:2016-07-01 05:09:01
【问题描述】:
这是我用于删除功能的代码。
在 RadgridItemdatabound 函数中,我必须包含这个...
foreach (GridColumn col in RadGrid1.MasterTableView.Columns)
{
dataItem["TemplateDeleteColumn"].Attributes.Add("onclick","CellClick('" + dataItem.ItemIndex + "','" + col.UniqueName + "');");
}
然后我必须创建 Itemcommand 函数。
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == "DeleteSelected")
{
GridDataItem item = (GridDataItem)e.Item;
var itemIndex = item.ItemIndex;
string LoginId = item.GetDataKeyValue("LoginId").ToString();
Int32 CampusCode = Convert.ToInt32(item.GetDataKeyValue("CampusCode"));
Definations def = new Definations();
Int32 Result = def.deleteUserAssignCampus(LoginId, CampusCode);
if (Result == 1)
{
BindDeptDatasimple();
cmbColumName.SelectedValue = "";
cmbDirection.SelectedValue = "";
Response.Redirect("UserCampus.aspx", false);
Session["deleteUserCampus"] = "Campus dissociated successfully.";
}
}
}
我无法在“var ItemIndex”中获取所选行的索引。 它总是在 ItemIndex 中返回零索引。这就是网格中第一行被删除的原因。如何获取选定行的选定索引?
【问题讨论】:
标签: telerik radgrid delete-row itemdatabound itemcommand