标题:在用GridView实现全选的反选时出错,,,求解!!!
只看楼主
zsqbctw
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-5-8
 问题点数:0 回复次数:1 
在用GridView实现全选的反选时出错,,,求解!!!
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
CheckBox cb = (CheckBox)sender;

if (cb.Text == "全选")
{
foreach (GridViewRow gv in this.GridView1.Rows)
{
CheckBox cd = (CheckBox)gv.FindControl("CheckBox1");
cd.Checked = cb.Checked;
cb.Text = "反选";
}
}
else
{
cb.Text = "反选";
foreach (GridViewRow gv in this.GridView1.Rows)
{
CheckBox cd = (CheckBox)gv.FindControl("CheckBox1");
cd.Checked = cb.Checked;(提示的出错位置!)
cb.Text = "全选";
}

}
}
搜索更多相关主题的帖子: CheckBox GridView Checked Text 
2008-05-08 13:51
zsqbctw
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-5-8
得分:0 
补充!!
<asp:TemplateField HeaderText="全选">
 <HeaderTemplate>
     &nbsp;
    <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged" />
   </HeaderTemplate>
 <ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" AutoPostBack="True"/>
   </ItemTemplate>                                                                                            
</asp:TemplateField>
2008-05-08 13:57



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-213153-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.100639 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved