日期:2014-05-20  浏览次数:20352 次

大哥们看下我这个关于gridview里checkbox的问题
<%@   Page   Language= "C# "   AutoEventWireup= "true "   CodeFile= "Default5.aspx.cs "   Inherits= "Default5 "   %>

<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<html   xmlns= "http://www.w3.org/1999/xhtml "   >
<head   runat= "server ">
        <title> 无标题页 </title>
</head>
<body>
        <form   id= "form1 "   runat= "server ">
        <div>
                &nbsp;
                <asp:Button   ID= "Button1 "   runat= "server "   OnClick= "Button1_Click "   Style= "left:   430px;
                        position:   absolute;   top:   424px "   Text= "Button "   />
                <asp:GridView   ID= "GridView1 "   runat= "server "   Style= "left:   205px;   position:   absolute;
                        top:   114px "   AutoGenerateColumns= "False "   Height= "237px "   Width= "374px ">
                        <Columns>
                                <asp:BoundField   DataField= "id "   HeaderText= "序号 "   />
                                <asp:BoundField   DataField= "Fname "   HeaderText= "用户名 "   />
                                <asp:BoundField   DataField= "password "   HeaderText= "密码 "   />
                                <asp:TemplateField> <ItemTemplate> <asp:CheckBox   ID= "checkbox1 "   runat=server   /> </ItemTemplate> </asp:TemplateField>
                                </Columns>
                </asp:GridView>
                &nbsp;
       
        </div>
        </form>
</body>
</html>


public   partial   class   Default5   :   System.Web.UI.Page
{
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {
                Session[ "constr "]   =   WebConfigurationManager.ConnectionStrings[0].ConnectionString;
                SqlDataSource   mysource   =   new   SqlDataSource((string)Session[ "constr "],   "select   *   from   test ");