Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

RadioButton list control must retain value on PostBack

Posted on 2009-05-13
2
Medium Priority
?
1,304 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

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

It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
While opting for any web-to-print solution, you need to discuss with your team and some of your end users and know their opinions about your decisions. In this article we list down some questions you need to ask yourself.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

636 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