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();
           
        }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值