Monday, 15 February 2010

asp.net - select all checkboxes using one checkbox in datalist -



asp.net - select all checkboxes using one checkbox in datalist -

this code when click on checkbox chkall , checkboxes should activated. can please help me

<asp:datalist id="datalist1" runat="server" onitemcommand="datalist1_itemcommand" cellpadding="4" forecolor="#333333"> <footerstyle backcolor="#507cd1" font-bold="true" forecolor="white" /> <headerstyle backcolor="#507cd1" font-bold="true" forecolor="white" /> <headertemplate> <asp:checkbox id="chkall" runat="server" onclick="checktrue()" /> empid ename designation doj salary deptno edit/update </headertemplate> <itemstyle backcolor="#eff3fb" /> <itemtemplate> <asp:checkbox id="chkone" runat="server" /> <asp:label id="lblempid" runat="server" text='<%#eval("empid") %>' /> <%#eval("ename") %> <%#eval("desg") %> <%#eval("doj") %> <%#eval("salary") %> <%#eval("deptno") %> <asp:button id="btnedit" runat="server" text="edit" commandname="edit" /> </itemtemplate> <alternatingitemstyle backcolor="white" /> <edititemtemplate> <asp:label id="lblempid" runat="server" text='<%#eval("empid") %>' /> <asp:textbox id="txtename" runat="server" text='<%#eval("ename") %>' /> <asp:textbox id="txtdesg" runat="server" text='<%#eval("desg") %>' /> <asp:textbox id="txtdoj" runat="server" text='<%#eval("doj") %>' /> <asp:textbox id="txtsalary" runat="server" text='<%#eval("salary") %>' /> <asp:textbox id="txtdeptno" runat="server" text='<%#eval("deptno") %>' /> <asp:button id="btnupdate" runat="server" text="update" commandname="update" /> <asp:button id="btncancel" runat="server" text="cancel" commandname="cancel" /> </edititemtemplate> <footertemplate> <asp:button id="btmdelete" runat="server" onclick="btndelete_click" text="delete" /> <asp:textbox id="txtempid" runat="server" width="60"></asp:textbox> <asp:textbox id="txtename" runat="server" width="60"></asp:textbox> <asp:textbox id="txtdesg" runat="server" width="60"></asp:textbox> <asp:textbox id="txtdoj" runat="server" width="60"></asp:textbox> <asp:textbox id="txtsalary" runat="server" width="60"></asp:textbox> <asp:textbox id="txtdeptno" runat="server" width="60"></asp:textbox> <asp:button id="btnadd" runat="server" text="add" commandargument="add" /> </footertemplate> <selecteditemstyle backcolor="#d1ddf1" font-bold="true" forecolor="#333333" /> </asp:datalist>

i recommend doing on client side. here illustration jquery

function checkall(){ $("#datalist1 :checkbox").prop("checked", $("#chkall").prop("checked")); }

asp.net checkbox datalist

No comments:

Post a Comment