Solved

RadioButton list control must retain value on PostBack

Posted on 2009-05-13
2
1,055 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! https://www.google.com/about/careers/students/guide-to-technical-development.html How to Know You are Making a Difference at EE In August, 2013, one …
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
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.

772 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

8 Experts available now in Live!

Get 1:1 Help Now