protected void Page_Load(object sender, EventArgs e) {
if (!this.IsPostBack) {
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("question", typeof(string)), new DataColumn("answer1", typeof(string)), new DataColumn("answer2", typeof(string)) });
dt.Rows.Add("what is name", "sagar", "nayak");
dt.Rows.Add("what is school", "saswat", "nayak");
dt.Rows.Add("what is name", "rahul", "nayak");
dlQuestion.DataSource = dt; dlQuestion.DataBind();
} }
<script type="text/javascript">
function RadioCheck(rb) {
$(rb).parent().css("font-weight", "bold");
var tblQuestionChoice = $("[id*=DataList1]");
var radioButton = $("[id*=DataList1]").find("input");
var row = rb.parentNode.parentNode;
for (var i = 0; i < radioButton.length; i++)
{
if (radioButton[i].type == "radio")
{
if (radioButton[i].checked && radioButton[i] != rb)
{
radioButton[i].checked = false;
$(radioButton[i]).parent().css("font-weight", "normal");
break;
}
} }
};</script></head><body>
<form id="form1" runat="server"> <div>
<table border="0" cellpadding="0" cellspacing="0">
<tr> <td>
<asp:DataList ID="dlQuestion" runat="server">
<ItemTemplate>
<p>
<%#Container.ItemIndex+1 %>
)
<asp:Label ID="Label1" runat="server" Text='<%# bind("question") %>'></asp:Label></p>
<table>
<tr>
<td>
<asp:RadioButton ID="rblOptionOne" onclick="RadioCheck(this);" GroupName="Questions" Text='<%# bind("answer1") %>'
runat="server" />
</td>
</tr>
<tr>
<td>
<asp:RadioButton ID="rblOptionTwo" onclick="RadioCheck(this);" GroupName="Questions" Text='<%# bind("answer2") %>'
runat="server" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
sir i want to change radio button text to bold onclick and if i click the other option the previously selected option should become normal