searchsanjaysharma
asked on
How to set the check the input type radio button based on dataset values.
I have the following code on .aspx page
<div style="text-align: center; float: left;">
<input type="radio" name="rbauthorship" value="First Author" runat="server" class="required" />
First Author
<input type="radio" name="rbauthorship" value="Corresponding Author" runat="server" class="required" />Corresponding Author
<input type="radio" name="rbauthorship" value="Co Author" runat="server" class="required" />
Co Author
</div>
On C# code behind, I am returning dataset which contains authorship values. I want Based on value returned the corresponding radiobutton should get checked.
string a=dt.Rows[0][0].ToString() ;
if(a=="First Author")
{
//What to write here so that first radio button gets checked
}
<div style="text-align: center; float: left;">
<input type="radio" name="rbauthorship" value="First Author" runat="server" class="required" />
First Author
<input type="radio" name="rbauthorship" value="Corresponding Author" runat="server" class="required" />Corresponding Author
<input type="radio" name="rbauthorship" value="Co Author" runat="server" class="required" />
Co Author
</div>
On C# code behind, I am returning dataset which contains authorship values. I want Based on value returned the corresponding radiobutton should get checked.
string a=dt.Rows[0][0].ToString()
if(a=="First Author")
{
//What to write here so that first radio button gets checked
}
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.