Results 1 to 6 of 6

Thread: [RESOLVED] [2008] selecting default item for RadioButtonList in asp.net 2.0

Hybrid View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2007
    Location
    Gothenburg - Sweden
    Posts
    149

    Resolved [RESOLVED] [2008] selecting default item for RadioButtonList in asp.net 2.0

    hello...
    i have a RadioButtonList in my web application which is developing by asp.net 2.0, i just need some help,
    Code:
    <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="true" >
                    <asp:ListItem>Month View</asp:ListItem>
                    <asp:ListItem>Week View</asp:ListItem>
                    <asp:ListItem>Day View</asp:ListItem>
                </asp:RadioButtonList>
    when the page loads by default the second item is selected, how can i change this default item?

    thanks
    In Love With .NET Framwork and Microsoft
    Learning ASP.NET,ADO.NET And VB.NET
    Becoming a Software Engineer...

  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: [2008] selecting default item for RadioButtonList in asp.net 2.0

    RadioButtonList1.SelectedIndex = 0

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2007
    Location
    Gothenburg - Sweden
    Posts
    149

    Re: [2008] selecting default item for RadioButtonList in asp.net 2.0

    where should i put it?
    i put it in page_load event, but doesn't work that way, its autopost back and everytime when i select something on everypage load the first item is selected, only on the first time that the page loads the fist item should be selected then the user can select anyone of them
    In Love With .NET Framwork and Microsoft
    Learning ASP.NET,ADO.NET And VB.NET
    Becoming a Software Engineer...

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

    Re: [2008] selecting default item for RadioButtonList in asp.net 2.0

    Place it in a Page.IsPostBack check so that the default item is selected only if the page is being loaded for the first time, but not during postbacks.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2007
    Location
    Gothenburg - Sweden
    Posts
    149

    Re: [2008] selecting default item for RadioButtonList in asp.net 2.0

    thanks alot... problem sloved
    In Love With .NET Framwork and Microsoft
    Learning ASP.NET,ADO.NET And VB.NET
    Becoming a Software Engineer...

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

    Re: [RESOLVED] [2008] selecting default item for RadioButtonList in asp.net 2.0

    No problem, feel free to post back any time you have more questions.

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