ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Get selected value of RadioButton within DataList in ASP.Net<p>Hi <a class="username" rel="Rucha"> Rucha</a>,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;asp:DataList ID=&#34;dlFeesDetails&#34; runat=&#34;server&#34; RepeatColumns=&#34;1&#34; CellSpacing=&#34;4&#34; RepeatLayout=&#34;Table&#34; RepeatDirection=&#34;Vertical&#34; BorderWidth=&#34;1px&#34; HorizontalAlign=&#34;Center&#34;&gt; &lt;ItemTemplate&gt; &lt;table class=&#34;table&#34;&gt; &lt;tr&gt; &lt;td colspan=&#34;1&#34;&gt; &lt;asp:RadioButton ID=&#34;RadioButton1&#34; runat=&#34;server&#34; name=&#34;rdGroup&#34; GroupName=&#34;a&#34; value=&#39;&lt;%# Eval(&#34;Total&#34;) %&gt;&#39; OnCheckedChanged=&#34;RadioButton1_CheckedChanged&#34; AutoPostBack=&#34;true&#34; /&gt; &lt;/td&gt; &lt;td colspan=&#34;2&#34;&gt; &lt;%# Eval(&#34;MainTitle&#34;) %&gt; &lt;/td&gt; &lt;td colspan=&#34;2&#34;&gt; &lt;asp:Label ID=&#34;lblTotal&#34; Text=&#39;&lt;%# Eval(&#34;Total&#34;) %&gt;&#39; runat=&#34;server&#34; /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/ItemTemplate&gt; &lt;/asp:DataList&gt; &lt;br /&gt; Total: &lt;asp:Label ID=&#34;lblTotal&#34; runat=&#34;server&#34; /&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Data;</pre> <p><strong>VB</strong></p> <pre class="brush: vb">Imports System.Data</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[2] { new DataColumn(&#34;MainTitle&#34;, typeof(string)), new DataColumn(&#34;Total&#34;, typeof(double))}); dt.Rows.Add(&#34;Symposium&#34;, 2950); dt.Rows.Add(&#34;Symposium1&#34;, 1500); dlFeesDetails.DataSource = dt; dlFeesDetails.DataBind(); } } protected void RadioButton1_CheckedChanged(object sender, EventArgs e) { RadioButton rb = (sender as RadioButton); if (rb.Checked) { Label total = (rb.NamingContainer).FindControl(&#34;lblTotal&#34;) as Label; lblTotal.Text = total.Text; } }</pre> <p><strong>VB</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If Not Me.IsPostBack Then Dim dt As DataTable = New DataTable() dt.Columns.AddRange(New DataColumn(1) {New DataColumn(&#34;MainTitle&#34;, GetType(String)), New DataColumn(&#34;Total&#34;, GetType(Double))}) dt.Rows.Add(&#34;Symposium&#34;, 2950) dt.Rows.Add(&#34;Symposium1&#34;, 1500) dlFeesDetails.DataSource = dt dlFeesDetails.DataBind() End If End Sub Protected Sub RadioButton1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Dim rb As RadioButton = (TryCast(sender, RadioButton)) If rb.Checked Then Dim total As Label = TryCast((rb.NamingContainer).FindControl(&#34;lblTotal&#34;), Label) lblTotal.Text = total.Text End If End Sub</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://i.imgur.com/8wkvM44.jpg" alt="" width="344" height="267" /></p>https://www.aspforums.net:443/Threads/104805/Get-selected-value-of-RadioButton-within-DataList-in-ASPNet/https://www.aspforums.net:443/Threads/104805/Get-selected-value-of-RadioButton-within-DataList-in-ASPNet/Tue, 17 Apr 2018 02:11:09 GMT