views:

920

answers:

1

I have a TemplateField in a DetailsView and its input should be one of a few choices in a lookup table. Currently it's a text field, but I want it to be a group of radio buttons, and it should work in both insert and edit mode (the correct current value should be selected in edit mode).

How do I create mutually exclusive radio buttons and databind them in a DetailsView TemplateField?

I'm on ASP.NET 3.5 using an Oracle database as a datasource.

+2  A: 
<EditItemTemplate>
    <asp:RadioButtonList ID="RadioButtonList1" runat="server" 
        DataSourceID="LookupSqlDataSource" DataTextField="LOOKUPITEM_DESCRIPTION" 
        DataValueField="LOOKUPITEM_ID" SelectedValue='<%# Bind("ITEM_ID")%>'>
    </asp:RadioButtonList>
</EditItemTemplate>

<InsertItemTemplate>
    <asp:RadioButtonList ID="RadioButtonList1" runat="server" 
        DataSourceID="LookupSqlDataSource" DataTextField="LOOKUPITEM_DESCRIPTION" 
        DataValueField="LOOKUPITEM_ID" SelectedValue='<%# Bind("ITEM_ID")%>'>
    </asp:RadioButtonList>
</InsertItemTemplate>
Gudmundur Orn
searching for how to do this in ASP.NET 2.0 since SelectedValue cannot set declaratively
paulwhit