Hi, I am using datagrid to display records from the table in my ASP.NET page(C#). Also I have a colounm which gives the option of selecting(check box) all the records display(just like yahoo/hotmail inbox) and then finally when the user hits the delete button, all the records selected gets deleted. Some how when I click on the select all checkbox, the javascrit does not get executed.I tried everything but it simply won't do it. I am pasting the code below:<form runat="server" id="form1" ><center><strong>List of Applicants</strong><br><br><asp:DataGrid id="dgOutput" runat="server" AllowSorting="True" AutoGenerateColumns="False" OnSortCommand="SortColumn" CellSpacing="5" CellPadding="3" BorderWidth="1px"> <Columns><asp:TemplateColumn> <HeaderTemplate> <asp:CheckBox ID="CheckAll" OnClick="javascript: return select_deselectAll(this.checked, this.id);" runat="server"/> </HeaderTemplate> <ItemTemplate> <asp:CheckBox ID="chkSelection" OnClick="javascript: return select_deselectAll(this.checked, this.id);" runat="server" /> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn SortExpression="login" HeaderText="LoginID"><ItemTemplate><asp:Label ID="lblStudentID" Text='<%# DataBinder.Eval(Container.DataItem,"login") %>' runat="server" /></ItemTemplate></asp:TemplateColumn> <asp:BoundColumn SortExpression="NameFirst" HeaderText="First Name" DataField="NameFirst" /> <asp:BoundColumn SortExpression="NameLast" HeaderText="Last Name" DataField="NameLast" /> </Columns> </asp:DataGrid><p></p><asp:button ID="btnShow" Text="Insert Selected Records" runat="Server" OnClick="insert_records" /></center><script>function select_deselectAll (chkVal, idval){ var frm=document.forms[0]; //Loop through all the items for (i=0 ; i<frm.length; i++) { //Look for the Header Template's Checkbox if(idVal.indexof ('CheckAll') != -1) { //Check if main checkbox is checked, then select or dselect datagrid checkboxes if(chkVal==true) { frm.elements[i].checked=true; } else { frm.elements[i].checked = false; } } else if (idVal.indexOf ('chkSelection') !=-1) { //Check if any of the checkboxes are not checked, and then uncheck top select all checkbox if (frm.elements[i].checked == false) { frm.elements[1].checked = false; //Uncheck main select all checkbox } } }} </script></form>
How do I make the javascript run? Actually I am quite new to ASP.NET so a detail code would really help me