ASP.net 2005 GridView中得到选择控件的值

来源:百度知道 编辑:UC知道 时间:2024/06/15 23:50:01
我想在一个按钮的CLECK事件里得到GridView中的CheckBox的值是true还是fals下面这这是按钮的CLECK事件里的代码,可是怎么也得不到高人指点,在线等
protected void Button1_Click(object sender, EventArgs e)
{
string str = "";
for (int i = 0; i < GridView1.Rows.Count; i++)
{
string aaa = (CheckBox)GridView1.Rows[i].Cells[10];
str = str + "," + GridView1.Rows[i].Cells[10].Text;
CheckBox chk = new CheckBox();
chk = (CheckBox)GridView1.Rows[i].Cells[10].FindControl("chkcheck");
CheckBox chk = (CheckBox)GridView1.Rows[i].Cells[10];
chk = (CheckBox)chk;

if (chk.Checked)
{
if (str == "")
{
str = GridView1.Rows[i].Cells[11].Text;
}
else
{
str = str + "," + Grid

string aaa = (CheckBox)GridView1.Rows[i].Cells[10];
str = str + "," + GridView1.Rows[i].Cells[10].Text;
CheckBox chk = new CheckBox();
chk = (CheckBox)GridView1.Rows[i].Cells[10].FindControl("chkcheck");
CheckBox chk = (CheckBox)GridView1.Rows[i].Cells[10];
这里有问题
Checkbox chk = (CheckBox)GridView1.Rows[i].FindControl("chkcheck");
这一句应该可以找到每一行的checkBox控件

//全选
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
cbox.Checked = true;
}