<asp:GridView ID="gvEmpDetails" runat="server" AutoGenerateColumns="false" onrowdatabound="gvEmpDetails_RowDataBound"> <Columns> <asp:TemplateField HeaderText="SelectAll"> <ItemTemplate> <asp:CheckBox ID="cbCheck" runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Empid" HeaderText="Id" /> <asp:BoundField DataField="Name" HeaderText="Name" /> <asp:BoundField DataField="Address" HeaderText="Address" /> <asp:BoundField DataField="Salary" HeaderText="Salary" /> <asp:TemplateField HeaderText="Edit"></asp:TemplateField> <asp:TemplateField HeaderText="Delete"></asp:TemplateField> </Columns> </asp:GridView>
if (e.Row.RowType == DataControlRowType.DataRow) { foreach (GridViewRow row in gvEmpDetails.Rows) { CheckBox chk = (CheckBox)e.Row.FindControl("cbCheck"); e.row.Attributes.Add("OnClick", ); } }
if (e.Row.RowType == DataControlRowType.DataRow) { foreach (GridViewRow row in gvEmpDetails.Rows) { CheckBox chk = (CheckBox)e.Row.FindControl("cbCheck"); e.row.Attributes.Add("OnClick", "RowClicked("+ chk.ClientID +")"); } } // Then in Javascript <code>RowClicked</code> method, // just set the checked property of the checkbox as desired // or call click event of checkbox or anything you feel like.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)