gridview在行中添加单击事件后,如何去除其中一列

2025-03-22 17:39:42
推荐回答(3个)
回答1:

实例:


前台页面:



















c#:

//获取批量删除的Id(Ids) 这里就是获取当前行的ID了
public string gvwCustomListDelByIds()
{
System.Text.StringBuilder columnIds = new System.Text.StringBuilder();

for (int i = 0; i <= gvwColumnList.Rows.Count - 1; i++)
{
System.Web.UI.HtmlControls.HtmlInputCheckBox cbx = (System.Web.UI.HtmlControls.HtmlInputCheckBox)gvwColumnList.Rows[i].FindControl("cbxContact");
if (cbx.Checked)
{
columnIds.Append(gvwColumnList.DataKeys[i].Value.ToString() + ",");
}
}
return columnIds.ToString().Trim(',');
}
//确认批量删除
protected void btnDel_Click(object sender, EventArgs e)
{
if (columnbll.ColumnDel(gvwCustomListDelByIds()))
{
Response.Write("");
}
else
{
Response.Write("");
}
bind();
}

回答2:

if(e.index != cloumns[CheckBox列])
{
单击事件;
}

回答3:

在GridView控件上查看“Properties”,属性中选择“Events”,将“Click”后面的事件函数删掉即可。