Results 1 to 2 of 2

Thread: Radiobuttonlist default selected item

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    240

    Radiobuttonlist default selected item

    Hi Guys,

    I have a problem with the radiobuttonlist.

    If I am going to edit the content of the radiobuttonlist manually I can easily set the default selected value.

    Code:
    <asp:RadioButtonList ID="rblItems" runat="server" RepeatDirection="Horizontal" AutoPostBack="True">
           <asp:ListItem Selected="True">Item 1</asp:ListItem>
           <asp:ListItem>Item 2</asp:ListItem>
           <asp:ListItem>Item 3</asp:ListItem>
    </asp:RadioButtonList>
    But how can I do this if the radiobuttonlist is bound in the database. This code below returns empty string.
    Code:
    rblItems.SelectedIndex = 1;
    Thanks

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Radiobuttonlist default selected item

    Empty string? Did you mean exception?

    Are you setting the SelectedIndex only after you've bound the radiobuttonlist?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width