日期:2014-05-17  浏览次数:20475 次

怎么遍历并获取GridView中checkBox是否选中以及该项的id???
在gridview表中我添加了复选框 
<asp:TemplateField HeaderText="全选">
                    <HeaderTemplate>
                        <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" 
                            oncheckedchanged="CheckBox1_CheckedChanged" Text=" " />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="ck" runat="server" oncheckedchanged="ck_CheckedChanged" />
                    </ItemTemplate>
                </asp:TemplateField>

.CS文件
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox all = (CheckBox)sender;
        foreach (GridViewRow g in GridView1.Rows)
        {
            CheckBox ck = (CheckBox)g.FindControl("ck");
            ck.Checked = all.Checked;
        }
    }
    protected void ck_CheckedChanged(object sender, EventArgs e)
    {

    }
现在我想获得选中项的id值,并根据此ID值,在弹出层中显示详细信息??请问如何实现着个过程