GridView中Checkbox使用一列
  <asp:GridView ID="GridViewAllUser" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" PageSize="1" RowHeaderColumn="UserID" DataSourceID="ObjectDataSource1" DataKeyNames="UserID">
                
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                
<EditRowStyle BackColor="#999999" />
                
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                
<Columns>
                    
<asp:BoundField DataField="UserID" HeaderText="UserID" />
                    
<asp:BoundField DataField="UserName" HeaderText="UserName" />
                    
<asp:BoundField DataField="LastActivityDate" />
                    
<asp:TemplateField HeaderText="IsApproved" SortExpression="IsApproved">
                
<EditItemTemplate>
                    
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("IsApproved") %>' />
                
</EditItemTemplate>
                
<ItemTemplate>
                    
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" Checked='<%# Bind("IsApproved") %>' OnCheckedChanged="CheckBox1_CheckedChanged"
                         
/>
                
</ItemTemplate>
            
</asp:TemplateField>
                
</Columns>
            
</asp:GridView>
           
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetAllRoles"
        TypeName
="AgTrade.WebSite.admin.UserManage"></asp:ObjectDataSource>

 

 


        
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
        
...{
            CheckBox cb 
= sender as CheckBox;
            GridViewRow gvr 
= cb.Parent.Parent as GridViewRow;
            
string userName = GridViewAllUser.DataKeys[gvr.RowIndex].Value.ToString();
           
        }

 

阅读更多
文章标签: asp server object string
想对作者说点什么? 我来说一句

获取GridViewCheckbox的值

2012年06月28日 17KB 下载

没有更多推荐了,返回首页

不良信息举报

GridView中Checkbox使用一列

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭