GridView与CheckBox

 a.aspx

<head runat="server">

    <title></title>

     <script language="javascript" type="text/javascript">

        function Allno(e)

        {

            var aa=document.getElementsByName("chkno");

            for(var i=0;i<17;i++)

            {

                aa[i].checked = e.checked;     

            }

        }

    </script>

<asp:GridView ID="GridView1"  runat="server" AutoGenerateColumns="False" AllowPaging="True" PageSize="20">

        <Columns>

           <asp:TemplateField>

           <HeaderTemplate>

           <input type="checkbox" name="chkAllno" title="全选" onclick="Allno(this)">

           </HeaderTemplate>

           <ItemTemplate>

           <input type="checkbox" name="chkno" value="<%#DataBinder.Eval(Container.DataItem,"PARAM_KJ_ID").ToString()%>" />

           </ItemTemplate>

           </asp:TemplateField>

           <asp:TemplateField HeaderText="序号">

                <ItemTemplate>

                    <%#Container.DataItemIndex+1 %>

                </ItemTemplate>

            </asp:TemplateField>

        </Columns>

</asp:GridView>

a.aspx.cs

   

string list = Request.Params["chkno"];

string[] Group = list.Split(',');

 

posted on 2008-12-18 16:00  张林春  阅读(265)  评论(0编辑  收藏  举报