Solved

Set selectedvalue on radiobuttonlist

Posted on 2009-05-20
3
416 Views
Last Modified: 2012-08-14
I have a radiobuttonlist in a form with three values and at some times I want to be able to update the form and then I want the selected radiobutton from before to be selected.

I've tried this and it works except that the actual radiobutton is'nt checked at update state.


<asp:RadioButtonList ID="rbAllowOptions" RepeatDirection="Horizontal" runat="server">

                <asp:ListItem Value="Credit Card" Text="Credit card" />

                <asp:ListItem Value="Invoice" Text="Invoice" />

                <asp:ListItem Value="Both" Text="Both" />

            </asp:RadioButtonList>
 

---------------------------------------------------------

Dim ccArray As New ArrayList

                                    ccArray = GetCreditCardDef(iIdentity) 'checks if Credit Card is selected
 

                                    If (ccArray(7) = "True") Then"

                                        rbAllowOptions.Items.FindByValue("Credit Card").Selected = True

                                    End If

Open in new window

0
Comment
Question by:mattegol
  • 2
3 Comments
 
LVL 4

Expert Comment

by:rdoran0928
ID: 24431556
you won't see the radio button checked until your page does a postback
0
 
LVL 4

Accepted Solution

by:
rdoran0928 earned 250 total points
ID: 24433075
There's a simpler way to set:

rbAllowOptions.SelectedValue = "Credit Card"

Also, you may have a problem in that value in text are different in case

<asp:ListItem Value="Credit Card" Text="Credit card" />

Value is upper case Card, text is lower case card
0
 

Author Comment

by:mattegol
ID: 24435016
Thanks for your comments I'm gonna test it tomorrow.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now