Note that there are some explanatory texts on larger screens.

plurals
  1. POTop (conditional) radio button always selected
    primarykey
    data
    text
    <p>I currently pass some values over to one of my ascx.cs files, and it displays certain radio buttons depending on the value that is sent over. The radio buttons are instantiated in the .ascx side of things:</p> <pre><code>&lt;asp:RadioButton ID="length5yr" GroupName="SubLength" runat="server" Visible ="false" /&gt; &lt;asp:label runat="server" id="Label5yr" Visible="false" style="width: 300px"&gt; &lt;/asp:label&gt; &lt;asp:RadioButton ID="length3yr" GroupName="SubLength" runat="server" Visible ="false" /&gt; &lt;asp:label runat="server" id="Label3yr" Visible="false" style="width: 300px"&gt; &lt;/asp:label&gt; &lt;asp:RadioButton ID="length2yr" GroupName="SubLength" runat="server" Visible ="false" /&gt; &lt;asp:label runat="server" id="Labelyr2" Visible="false" style="width: 300px"&gt; &lt;/asp:label&gt; &lt;asp:RadioButton ID="length1yr" GroupName="SubLength" runat="server" Visible ="false" /&gt; &lt;asp:label runat="server" id="Label1yr" Visible="false" style="width: 300px"&gt; &lt;/asp:label&gt; &lt;asp:RadioButton ID="lengthQuarterly" GroupName="SubLength" runat="server" Visible ="false" /&gt; &lt;asp:label runat="server" id="labelQuarterly" Visible="false" style="width: 300px"&gt; &lt;/asp:label&gt; &lt;asp:RadioButton ID="lengthMonthly" GroupName="SubLength" runat="server" Visible ="false" /&gt; &lt;asp:label runat="server" id="labelMonthly" Visible="false" style="width: 300px"&gt; &lt;/asp:label&gt; </code></pre> <p>I want whichever radio button that ends up being the first/top one displayed to be checked. I've been able to get the last radio button checked (which also gives me other problems anyways) - but how can I get that top one checked!?</p> <p>This is the code for how I determine which radio button is displayed - I have only shown one of the options just to make the code a little bit easier to read.</p> <pre><code> foreach (Dictionary&lt;string, string&gt; d in orderOptions) { if (d["length"] == "one") { length1yr.Visible = true; price1yr = d["price"]; rate1yr = d["rate"]; issues1yr = d["issues"]; premium1yr = d["premium"]; Label1yr.Text = d["description"] + "&lt;br&gt;&lt;br&gt;"; Label1yr.Visible = true; SubLength1yr = "1 year"; } </code></pre>
    singulars
    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.
 

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