Last post May 19, 2010 07:37 AM by joy_vinod
Nov 29, 2006 02:52 PM|JoeBob49|LINK
I have read through many posts on this subject, but nothing seems to directly address my issue (or I've completely misunderstood the answer).
Example: I have three buttons in the Radio Button List labeled Yes, No and NA with values of 1,2 and 3 respectively. I created the list from the Edit Items screen for the control. I want to bind that list to a field called Answer in an SQL Server table
so when the user clicks button labeled YES, a value of 1 goes into the Answer field. Question 1: Is there a property on the RB List that can be bound the same way one binds a text box? Everything I've seen suggests some sort of code manipulation to bind
the value coming from the SelectedValue property.
Question 2: When a value is returned from the Answer field on postback (let's say the value is 3), the only button to show up in the list is NA (which I set with the value of 3). I need the other buttons to stay visible since they are the alternative choices
and the user may want to change the answer. What's up with that?
I'm working on a small survey form where these radio buttons are crucial. I've looked in several books, web sites, contacted some developers; no luck. Either they don't understand what I'm trying to accomplish or it can't be done. I find it hard to believe
that there can be controls as complex and sophisticated as the Gridview and this Radio Button List this is such a headache.
Any and all help is appreciated! Thanks!
asp.NET 2.0 C#
Nov 17, 2007 06:14 AM|shauntck|LINK
Have been trying to do the exact same thing. If you figure it out please let us know. For some reason this is tough to do.
Jun 27, 2008 11:48 AM|ed_ward_graham|LINK
Did you ever try including SelectedValue='<%# Bind("Answer") %>' in the properties for the radio-button list? I am using a FormView and the following worked for me (in the InsertItemTemplate):
<asp:RadioButtonList ID="Title" runat="server" RepeatDirection="Horizontal" SelectedValue='<%# Bind("Title") %>'>
May 19, 2010 07:37 AM|joy_vinod|LINK
Thanks, Ed Graham,
Yes, SelectedValue, worked in my case, too.
The thing is, it does not show the property in the intellisense of the RadioButtonList in the design view. But as RadioButtonList inherits ListControl, the SelectedValue property is available/accessible in RadioButtonList, too. :)
radio button list
option button list