首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

小弟我想获取GRIDVIEW控件中插入CHECKBOX控件中的一个值

2012-01-11 
我想获取GRIDVIEW控件中插入CHECKBOX控件中的一个值int intCount this.GridView1.Rows.Countfor (int i

我想获取GRIDVIEW控件中插入CHECKBOX控件中的一个值
int intCount = this.GridView1.Rows.Count;
  for (int i = 0; i < intCount; i++)
  {
  CheckBox CheckBox1 = this.GridView1.Rows[i].Cells[5].FindControl("CheckBox1") as CheckBox;
  if (CheckBox1.Checked)
  {
  string title =this.GridView1.Rows[i].Cells[1].Text;
  SqlWebDal swd = new SqlWebDal();
  string sqlcontent = "UPDATE Tips SET Release ='true' WHERE Title='" + title + "'";
  swd.GetSqlCmd(sqlcontent);
  }
  }
  Response.Write("<script language='javascript'>alert('发布成功')</script>");
  Response.Write();

[解决办法]
Checkbox test =(CheckBox)GridView1.rows[i].FindControls("yourControlName");

string title = test.Checked.toString()

热点排行