先有一个GridView1,其中第三列为checkboxfield,当选择checked==ture时,将该行的第一列的name写入自定义string型的name中,代码应该怎样写呢?if (ck.Checked == true)
{
string name = (GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).ToString();
Label1.Text = name;
} 这样写显示的错误是:指定的参数已超出有效值的范围。参数名: index
{
string name = (GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).ToString();
Label1.Text = name;
} 这样写显示的错误是:指定的参数已超出有效值的范围。参数名: index
{
string name = (GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).ToString();
Label1.Text = name;
}
触发哪个事件执行?
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
CheckBox cb = GridView1.Rows[e.RowIndex].Cells[2].Controls[0] as CheckBox;
if (ck.Checked == true)
{
string name = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[0].Controls[0])).Text.ToString().Trim();
Label1.Text = name;
}
}
{
string str;
string id=this.GridView1.DataKeys[e.RowIndex].Value.ToString();
CheckBox ck = (CheckBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0];
if (ck.Checked == true)
{
str = "1"; string name = (GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).ToString();
Label1.Text = name; }
else
{
str = "0";
}