Solved

RadioButton list control must retain value on PostBack

Posted on 2009-05-13
2
1,130 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 250 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 250 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

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