当删除按钮被C#代码设置为禁用时,gridview的取消按钮不起作用(如果lbltype.Text!= admin,则删除按钮设置为禁用)。因此,当我点击编辑时,我无法取消编辑,因为按钮被禁用请参阅下面的Gridview图像
C#代码
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
lbltype.Text = Session["Type"].ToString();
DataRowView drv = e.Row.DataItem as DataRowView;
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (lbltype.Text != "admin")
{
LinkButton editLink = (LinkButton)e.Row.Cells[6].Controls[2];
editLink.Enabled = false;
}
}
if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowIndex != GridView1.EditIndex)
{
(e.Row.Cells[6].Controls[2] as LinkButton).Attributes["onclick"] = "return confirm('Do you want to delete this row?');";
}
}