?
Solved

RadioButton list control must retain value on PostBack

Posted on 2009-05-13
2
Medium Priority
?
1,342 Views
Last Modified: 2012-05-06
I have the below RadioList Control below. On page load it should have a SelectedValue of 0. However I need this control to force a postback (notice the AutoPostBack ='true') because I have a OnSelectedIndex changed method that will manipulate the appearance of the page on which this control sits.  When the selected index changes I would like this control to display and retain its newly selected value. How do I get this control to retain its value on postback? Any help would be greatly appreciated.
<asp:RadioButtonList ID="rbtcuscomplaint" runat="server" RepeatDirection="Horizontal" OnSelectedIndexChanged="rbtcuscomplaint_SelectedIndexChanged" AutoPostBack="true">
                <asp:ListItem Selected="true" Value="0" Text="Customer Order"></asp:ListItem>
                <asp:ListItem Selected="false" Value="1" Text="Customer Tehnical Support"></asp:ListItem>
                <asp:ListItem Selected="false" Value="2" Text="Customer Suggestion"></asp:ListItem>
           </asp:RadioButtonList>

Open in new window

0
Comment
Question by:jazzcatone
2 Comments
 
LVL 39

Accepted Solution

by:
abel earned 1000 total points
ID: 24374698
Normally, EnableViewState is true. Please check if that's true for you too. Then, inside your page load, you say you set the value to 0, did you put that code into and IsPostBack block?:

if(!this.IsPostBack)
{
    rbtcuscomplaint.SelectedValue = "0";
}

which will effectively prevent that on postback (when the user clicks something and the form is posted back to the server, that is called the postback), the selected value is not changed.
0
 
LVL 10

Assisted Solution

by:MaxOvrdrv2
MaxOvrdrv2 earned 1000 total points
ID: 24374770
what he said... put the default value in the IsPostBack block:

VBNet:


page_load
if page.isPostBack=false then
   rbcuscomplaint.SelectedValue="0"
end if
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

839 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