Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. check box inside the gridview

check box inside the gridview

Scheduled Pinned Locked Moved C#
javascripthtmlsysadmintoolshelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chithra r
    wrote on last edited by
    #1

    hi all i have resolved the problem.here is the code aspx page <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> <script type="text/javascript"> function SelectAll(id) { var frm = document.forms[0]; for (i=0;i<frm.elements.length;i++) { if (frm.elements[i].type == "checkbox") { frm.elements[i].checked = document.getElementById(id).checked; } } } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" Width="400px" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound"> <Columns> <asp:BoundField DataField="PersonID" HeaderText="PersonID" InsertVisible="False" ReadOnly="True" /> <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /> <asp:TemplateField> <%--<AlternatingItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" /> </AlternatingItemTemplate>--%> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" /> </ItemTemplate> <HeaderTemplate> <asp:CheckBox ID="cbSelectAll" runat="server" Text="Select All" /> </HeaderTemplate> <HeaderStyle HorizontalAlign="Left" /> <ItemStyle HorizontalAlign="Left" /> </asp:TemplateField> </Columns> </asp:GridView> </div> </form> </body> </html> code behind protected void Page_Load(object sender, EventArgs e) { BindGrid(); } private void BindGrid() { string Connstr = "connection string"; SqlConnection Conn = new SqlConnection(Connstr); string str = "select * from emp"; SqlCommand cmd = new SqlCommand(str, Conn); Conn.Open(); DataSet ds = new DataSet(); SqlDataAdapter Adap = new SqlDataAdapter(); Adap.SelectCommand = cmd; Adap.Fi

    T N 2 Replies Last reply
    0
    • C chithra r

      hi all i have resolved the problem.here is the code aspx page <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> <script type="text/javascript"> function SelectAll(id) { var frm = document.forms[0]; for (i=0;i<frm.elements.length;i++) { if (frm.elements[i].type == "checkbox") { frm.elements[i].checked = document.getElementById(id).checked; } } } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" Width="400px" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound"> <Columns> <asp:BoundField DataField="PersonID" HeaderText="PersonID" InsertVisible="False" ReadOnly="True" /> <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /> <asp:TemplateField> <%--<AlternatingItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" /> </AlternatingItemTemplate>--%> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" /> </ItemTemplate> <HeaderTemplate> <asp:CheckBox ID="cbSelectAll" runat="server" Text="Select All" /> </HeaderTemplate> <HeaderStyle HorizontalAlign="Left" /> <ItemStyle HorizontalAlign="Left" /> </asp:TemplateField> </Columns> </asp:GridView> </div> </form> </body> </html> code behind protected void Page_Load(object sender, EventArgs e) { BindGrid(); } private void BindGrid() { string Connstr = "connection string"; SqlConnection Conn = new SqlConnection(Connstr); string str = "select * from emp"; SqlCommand cmd = new SqlCommand(str, Conn); Conn.Open(); DataSet ds = new DataSet(); SqlDataAdapter Adap = new SqlDataAdapter(); Adap.SelectCommand = cmd; Adap.Fi

      T Offline
      T Offline
      Thats Aragon
      wrote on last edited by
      #2

      Hi Chithra, What is the problem? Please explain the problem.

      Regards :) "Don't forget to vote" ;) ;P ;)

      C 1 Reply Last reply
      0
      • C chithra r

        hi all i have resolved the problem.here is the code aspx page <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> <script type="text/javascript"> function SelectAll(id) { var frm = document.forms[0]; for (i=0;i<frm.elements.length;i++) { if (frm.elements[i].type == "checkbox") { frm.elements[i].checked = document.getElementById(id).checked; } } } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" Width="400px" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound"> <Columns> <asp:BoundField DataField="PersonID" HeaderText="PersonID" InsertVisible="False" ReadOnly="True" /> <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /> <asp:TemplateField> <%--<AlternatingItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" /> </AlternatingItemTemplate>--%> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" /> </ItemTemplate> <HeaderTemplate> <asp:CheckBox ID="cbSelectAll" runat="server" Text="Select All" /> </HeaderTemplate> <HeaderStyle HorizontalAlign="Left" /> <ItemStyle HorizontalAlign="Left" /> </asp:TemplateField> </Columns> </asp:GridView> </div> </form> </body> </html> code behind protected void Page_Load(object sender, EventArgs e) { BindGrid(); } private void BindGrid() { string Connstr = "connection string"; SqlConnection Conn = new SqlConnection(Connstr); string str = "select * from emp"; SqlCommand cmd = new SqlCommand(str, Conn); Conn.Open(); DataSet ds = new DataSet(); SqlDataAdapter Adap = new SqlDataAdapter(); Adap.SelectCommand = cmd; Adap.Fi

        N Offline
        N Offline
        Nouman Bhatti
        wrote on last edited by
        #3

        what is the question :doh:

        1 Reply Last reply
        0
        • T Thats Aragon

          Hi Chithra, What is the problem? Please explain the problem.

          Regards :) "Don't forget to vote" ;) ;P ;)

          C Offline
          C Offline
          chithra r
          wrote on last edited by
          #4

          have a look into my last post(posted 24th march).it is in the 5th page of c# message board. :)

          pintoo

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups