检查后,GridView内部复选框的状态未更改 [英] status of checkbox inside gridview not changed after checking

查看:61
本文介绍了检查后,GridView内部复选框的状态未更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

foreach(GridView1.Rows中的GridViewRow rowItem)
{
CheckBox chk =(CheckBox)(rowItem.Cells [7] .FindControl("ch1")));

if(chk!= null && chk.Checked)
{

SqlConnection myConnection =新的SqlConnection(数据源= PCIMS051;初始目录= unblockingwebsite;集成安全性= True");
myConnection.Open();


SqlCommand myCommand =新的SqlCommand("INSERT INTO twebsite_unblocking(Requested_Status)" +
值(" 2)",myConnection);
}
}

foreach (GridViewRow rowItem in GridView1.Rows)
{
CheckBox chk = (CheckBox)(rowItem.Cells[7].FindControl("ch1"));

if (chk != null && chk.Checked)
{

SqlConnection myConnection = new SqlConnection("Data Source=PCIMS051;Initial Catalog=unblockingwebsite;Integrated Security=True");
myConnection.Open();


SqlCommand myCommand = new SqlCommand("INSERT INTO twebsite_unblocking (Requested_Status) " +
"Values (''2'')", myConnection);
}
}

推荐答案

在设计页面中使用AutoPostBack ="true".

就像
< asp:checkbox id ="CheckBox1" runat ="server" autopostback ="true" xmlns:asp =#unknown">



给该问题更多的解释,您的问题未清除
Use AutoPostBack="true" in design page.

like
<asp:checkbox id="CheckBox1" runat="server" autopostback="true" xmlns:asp="#unknown">

OR

Give some more explanation for the problem, your question not cleared


这篇关于检查后,GridView内部复选框的状态未更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆