How to bind DataGrid RadioButtonList's value?

G

Guest

Hello, I need to set the selection in the RadioButtonList according to the
value of SelectedValue in the underlying dataset - please suggest. The code
is below. Thank you.

<asp:TemplateColumn>
<HeaderStyle Width="7px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:RadioButtonList DataTextField="SelectedValue"
DataValueField="SelectedValue" RepeatDirection="Horizontal" ID="Selection"
Runat="server">
<asp:ListItem Selected="False">Yes</asp:ListItem>
<asp:ListItem Selected="False">No</asp:ListItem>
<asp:ListItem Selected="True">N/A</asp:ListItem>
</asp:RadioButtonList>
 
G

Guest

Jeff, hi again, I just figured it out:

<asp:RadioButtonList SelectedIndex='<%#
Convert.ToInt32(DataBinder.Eval(Container.DataItem, "SelectedValue"))%>'
DataValueField="SelectedValue" RepeatDirection="Horizontal" ID="Selection"
Runat="server">

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top