Click here to Skip to main content
15,117,549 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<asp:RadioButtonList runat="server" SelectedValue='<%#(Convert.ToString(Eval("Answerid")) != "0"  ? Convert.ToString(Eval("Answerid")):"5") %>'
                                            ID="Radiobtnanswer" RepeatColumns="1" RepeatDirection="Vertical">
                                            <asp:ListItem Value="1"></asp:ListItem>
                                            <asp:ListItem Value="2"></asp:ListItem>
                                            <asp:ListItem Value="3"></asp:ListItem>
                                            <asp:ListItem Value="4"></asp:ListItem>
                                            <asp:ListItem Value="5" Text="" style="display: none" />
                                        </asp:RadioButtonList>

I want like this:

<asp:RadioButtonList runat="server" SelectedValue='<%#(Convert.ToString(Eval("Answerid")) != "0"  ? Convert.ToString(Eval("Answerid")):"5") %>'
                                           ID="Radiobtnanswer" RepeatColumns="1" RepeatDirection="Vertical">
                                           <asp:ListItem Value="1" Text='<%Bind("abc")%>></asp:ListItem>
                                           <asp:ListItem Value="2"></asp:ListItem>
                                           <asp:ListItem Value="3"></asp:ListItem>
                                           <asp:ListItem Value="4"></asp:ListItem>
                                           <asp:ListItem Value="5" Text="" style="display: none" />
                                       </asp:RadioButtonList>
Posted
Updated 23-Feb-12 4:17am
v2
Comments
BobJanova 23-Feb-12 9:18am
   
I updated the question to fix the tags.

However, you haven't really asked a question, so it still needs clarification from you.

1 solution

Let us assume radiobuttonlist as Radiobtnanswer and list of text value as actionList. Try the below code:

C#
radiobuttonlist.Items.AddRange(actionList.ToArray());
radiobuttonlist.DataBind();
   
Comments
sharad_sharma82 24-Feb-12 0:54am
   
but my each value field need to bind with different field values:
value="1" text=<%=Bind(abc)%>
value="2" text=<%=Bind(abc2)%>
value="3" text=<%=Bind(abc3)%>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900