I have a radio button list which I bind with the data source with the following code and it shows as the desired result for me:
dv.RowFilter = "VoteId = " + grdVote.DataKeys[e.Row.RowIndex].Value;
rdbList.DataSource = dv;
rdbList.DataTextField = "VoteOption";
rdbList.DataValueField = "VoteOptionId";
rdbList.DataBind();
Now my question is how can I show the alphabetical serial number with each radio button list items.in below image there should be 'A' before apple and 'B' before banana and so on.....
Unfortunately, it will not be possible with radio button list unless you are ready to change your data source to have text values prefixed with letters (although that will also not generate the correct layout).
In general, I am not fan of markup (html) generated by radio button list and suggest using a repeater to get the layout with the correct semantic html. For example,
<asp:Repeater runat="server" ID="optionList">
<HeaderTemplate><ol class="optionList" type="A"></HeaderTemplate>
<ItemTemplate>
<li>
<input type="radio" name="VoteList" value='<%# Eval("VoteOptionId") %>' />
<%# Eval("VoteOption") %>
</li>
</ItemTemplate>
<FooterTemplate></ol></FooterTemplate>
</asp:Repeater>
To access the selected radio-button, you can use Request.Form["VoteList"]
EDIT: If you must use radio button, one of the idea could be modifying the text once the list has been data-bound. For example,
protected void Page_PreRender(object sender, EventArgs e)
{
for (int i=0; i < rdbList.Items.Count; i++)
{
rdbList.Items[i].Text = Convert.ToChar(65 + i).ToString() + " " + rdbList.Items[i].Text;
}
}