GridView模板里面的CheckBox选中后台获取不到
展开全部
//删除数据闷顷
protected void bt_delete_Click1(object sender, EventArgs e)
{
for (int i = 0; i < gdv_Bank.Rows.Count; i++)
{
GridViewRow row = gdv_Bank.Rows[i];
Label ln = (Label)row.Cells[0].FindControl("LabVisible");
CheckBox box = (CheckBox)row.Cells[0].FindControl("CheckSelect");
if (box.Checked == true)
{
string sql_delete = "delete from bankinfo where Id='蚂租陆"型羡 + ln.Text.Trim().ToString() + "'";
dbCon.deleteData(sql_delete);
}
}
DataBindToGridview("order by id desc");//重新绑定Gridview
}
protected void bt_delete_Click1(object sender, EventArgs e)
{
for (int i = 0; i < gdv_Bank.Rows.Count; i++)
{
GridViewRow row = gdv_Bank.Rows[i];
Label ln = (Label)row.Cells[0].FindControl("LabVisible");
CheckBox box = (CheckBox)row.Cells[0].FindControl("CheckSelect");
if (box.Checked == true)
{
string sql_delete = "delete from bankinfo where Id='蚂租陆"型羡 + ln.Text.Trim().ToString() + "'";
dbCon.deleteData(sql_delete);
}
}
DataBindToGridview("order by id desc");//重新绑定Gridview
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
估计你用的是客户端的checkbox,迹斗参考下面的代码吧,肯定可以的。
Page:
<asp:TemplateField HeaderText="选择" >
<ItemTemplate>
<asp:CheckBox ID="chk" runat="server" />
</ItemTemplate>吵州姿升绝
<ItemStyle Width="20px" />
</asp:TemplateField>
CS:
for (int i = 0; i < gvData.Rows.Count; i++)
{
if (((CheckBox)gvData.Rows[i].FindControl("chk")).Checked)
{
pr_no = pr_no + ",'" + gvData.DataKeys[i]["pr_no"].ToString() + "'";
num = num + 1;
}
}
Page:
<asp:TemplateField HeaderText="选择" >
<ItemTemplate>
<asp:CheckBox ID="chk" runat="server" />
</ItemTemplate>吵州姿升绝
<ItemStyle Width="20px" />
</asp:TemplateField>
CS:
for (int i = 0; i < gvData.Rows.Count; i++)
{
if (((CheckBox)gvData.Rows[i].FindControl("chk")).Checked)
{
pr_no = pr_no + ",'" + gvData.DataKeys[i]["pr_no"].ToString() + "'";
num = num + 1;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询