Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since a <strong>gridview is rendered as table element , at run time it will assign different "name" to each radio button</strong> giving GroupName won't work. </p> <p>But calling a JavaScript function for validating the radio button to select one radio button at a time instead of giving same GroupName for multiple radio button outside gridview.</p> <p>The javascript function sets the row of the current selected radio button's style to determine that the row is selected and then loops through the radio buttons in the gridview and then de-select the previous selected radio button and set the row style back to its default.</p> <p>See the code below,</p> <p>JavaScript section,</p> <pre><code> &lt;script language="javascript" type="text/javascript"&gt; function CheckOtherIsCheckedByGVID(rb) { var isChecked = rb.checked; var row = rb.parentNode.parentNode; var currentRdbID = rb.id; parent = document.getElementById("&lt;%= GridView1.ClientID %&gt;"); var items = parent.getElementsByTagName('input'); for (i = 0; i &lt; items.length; i++) { if (items[i].id != currentRdbID &amp;&amp; items[i].type == "radio") { if (items[i].checked) { items[i].checked = false; } } } } &lt;/script&gt; </code></pre> <p>Aspx section,</p> <pre><code> &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"&gt; &lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:RadioButton runat="server" ID="RadioButton1" onclick="javascript:CheckOtherIsCheckedByGVID(this);"&gt; &lt;/asp:RadioButton&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p><strong>NOTE:</strong> the onclick used here is th html property and will appear within intellisense property of visual studio. So just type this as provided in my code.</p> <p>I tested this and worked perfectly for me.</p> <p>Hope this will work for you..</p>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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