Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with Check box Header in Grid view
    primarykey
    data
    text
    <p>I am having 2 radio buttons on my web form namely <code>Radio1</code> and <code>Radio2</code>. Based on these selection i will show a <code>GridView</code> with <code>Check box</code> selection along with some data. This <code>GridView</code> has a header check box through which i can select all check boxes available in <code>gridview</code>. But on selecting this the Radio button selection is also getting changed. Means if i have my <code>Radio1</code> as selected initially and if i click on check box which is available as header the radio button selection is switched to <code>Radio2</code>Why this is happening can any one tell.</p> <p>Script i used for selecting check boxes</p> <pre><code>&lt;script type="text/javascript"&gt; function check_uncheck (Val) { var ValChecked = Val.checked; var ValId =Val.id; var frm = document.forms[0]; // Loop through all elements for (i=0; i&lt;frm.length; i++) { // Look for Header Template's Checkbox if (this!=null) { if (ValId.indexOf ('CheckAll') != -1) { // Check if main checkbox is checked, then select or deselect datagrid checkboxes if(ValChecked) frm.elements[i].checked = true; else frm.elements[i].checked = false; } else if (ValId.indexOf ('checkRec') != -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; } } } } &lt;/script&gt; </code></pre> <p>My grid view design</p> <pre><code>&lt;asp:GridView ID="grdPayroll" runat="server" HeaderStyle-BackColor="green" AutoGenerateColumns="False" CssClass="grid_cen" Font-Names="Arial" Font-Size="11pt" AlternatingRowStyle-BackColor="#C2D69B" CellPadding="4" CellSpacing="10" ForeColor="Black" GridLines="Vertical" PageSize="5" Visible="False" BackColor="Black" BorderColor="#d3d4d3" BorderStyle="None" BorderWidth="1px"&gt; &lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:CheckBox ID="checkRec" runat="server" onclick="return check_uncheck (this );" /&gt; &lt;/ItemTemplate&gt; &lt;HeaderTemplate&gt; &lt;asp:CheckBox ID="CheckAll" runat="server" onclick="return check_uncheck (this );" /&gt; &lt;/HeaderTemplate&gt; &lt;/asp:TemplateField&gt; &lt;%--&lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:RadioButton ID="rdbtnPayroll" runat="server" onclick="RadioCheck(this);" /&gt; &lt;/ItemTemplate&gt; &lt;&lt;&lt;&lt;&lt;&lt;&lt; .mine &lt;/asp:TemplateField&gt;--%&gt; &lt;asp:BoundField DataField="EmpID" HeaderText="Employee ID"&gt; &lt;ItemStyle Width="100px" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="empname" HeaderText="Employee Name"&gt; &lt;ItemStyle Width="100px" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="PayPeriodNumber" HeaderText="PayPeriod Number"&gt; &lt;ItemStyle Width="100px" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="PayRollYear" HeaderText="Payroll Year"&gt; &lt;ItemStyle Width="100px" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="PaymentDate" HeaderText="Payment Date"&gt; &lt;ItemStyle Width="100px" /&gt; &lt;/asp:BoundField&gt; &lt;/Columns&gt; &lt;HeaderStyle BackColor="#d6dee7" Font-Bold="True" ForeColor="black" Font-Size="smaller" /&gt; &lt;AlternatingRowStyle BackColor="White" /&gt; &lt;EmptyDataTemplate&gt; &lt;h1&gt; No Data Found&lt;/h1&gt; &lt;/EmptyDataTemplate&gt; &lt;RowStyle BackColor="#e7eff7" Font-Size="XX-Small" CssClass="text_center" /&gt; &lt;FooterStyle BackColor="#CCCC99" /&gt; &lt;PagerStyle BackColor="#e7eff7" ForeColor="Black" HorizontalAlign="Right" Font-Size="XX-Small" /&gt; &lt;SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" /&gt; &lt;/asp:GridView&gt; </code></pre> <p>My Radio buttons</p> <pre><code> &lt;asp:RadioButton ID="rdbtnsimulation" Text="Simulation" runat="server" AutoPostBack="True" GroupName="Run" OnCheckedChanged="rdbtnsimulation_CheckedChanged" /&gt; &lt;asp:RadioButton ID="rdbtnlive" Text="live" runat="server" AutoPostBack="True" GroupName="Run" OnCheckedChanged="rdbtnlive_CheckedChanged" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload