当前位置: 代码迷 >> ASP.NET >> 小弟我想获取GRIDVIEW控件中插入CHECKBOX控件中的一个值
  详细解决方案

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

热度:6608   发布时间:2013-02-25 00:00:00.0
我想获取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()
  相关解决方案