GridView中Checked选取任何一行或多行,然后单击保存按钮,并不是取DataKeys的值,而是取得任意一列的值 30
我的代码如下:protectedvoidButton2_Click(objectsender,EventArgse){stringMstr="";CheckBoxMych...
我的代码如下:
protected void Button2_Click(object sender, EventArgs e)
{
string Mstr = "";
CheckBox MychBox;
foreach (GridViewRow G in GridView1.Rows)
{
MychBox = (CheckBox)G.FindControl("CheckBox1");
if (MychBox.Checked)
// CheckBox contact_Box = (CheckBox)GridView1.Rows[G.RowIndex].FindControl("CheckBox1");
//contact_str = contact_Box.Text;
Mstr += Rowview.Cells[1].text + ",";
}
if (Mstr.Length <= 0)
return;
else
Mstr = Mstr.Substring(0, Mstr.Length - 1);
Response.Write(Mstr);
}
其中"Mstr += Rowview.Cells[1].text + ",";"这个地方怎么写才有效,我写的是错误的. 展开
protected void Button2_Click(object sender, EventArgs e)
{
string Mstr = "";
CheckBox MychBox;
foreach (GridViewRow G in GridView1.Rows)
{
MychBox = (CheckBox)G.FindControl("CheckBox1");
if (MychBox.Checked)
// CheckBox contact_Box = (CheckBox)GridView1.Rows[G.RowIndex].FindControl("CheckBox1");
//contact_str = contact_Box.Text;
Mstr += Rowview.Cells[1].text + ",";
}
if (Mstr.Length <= 0)
return;
else
Mstr = Mstr.Substring(0, Mstr.Length - 1);
Response.Write(Mstr);
}
其中"Mstr += Rowview.Cells[1].text + ",";"这个地方怎么写才有效,我写的是错误的. 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询