check box inside the gridview
-
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 -
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.FiHi Chithra, What is the problem? Please explain the problem.
Regards :) "Don't forget to vote" ;) ;P ;)
-
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.Fiwhat is the question :doh:
-
Hi Chithra, What is the problem? Please explain the problem.
Regards :) "Don't forget to vote" ;) ;P ;)