62,041
社区成员
发帖
与我相关
我的任务
分享
for (int i = 0; i < this.GridView1.Rows.Count; i++)
{
//查找单选框按钮
CheckBox cb = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("cbDel");
//隐藏控件,值为表的主键
HiddenField hf = (HiddenField)GridView1.Rows[i].Cells[0].FindControl("hfsID");
//判断单选框是否被选择
if (cb.Checked)
{
//主键之间用逗号隔开
ID = string.Format(ID + hf.Value + "{0}",i==this.GridView1.Rows.Count ? "" : ",";
}
}
string a="a,b,c,d,";
string b=a.Trim(',');
if (cb.Checked)
{
//主键之间用逗号隔开
ID = ID + hf.Value + " "; }
}
ID = ID.TrimEnd(',');
...