Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Data Bound Controls

Reply
Thread Tools

Data Bound Controls

 
 
Karen A Hodge
Guest
Posts: n/a
 
      06-12-2004
I have a RadioButtonList on my form. There are only two items in the
collection, "No" = 0, and "Yes" = 1. I have the SelectedIndex property bound
to a SQL Server table which has a column of datatype, bit. The default value
is zero for that column. I expect that after the databinding occurs, any
value of 1 would have "Yes" selected and that 0 would have "No" selected,
instead, neither are selected as if the selected index were -1.
What am I doing wrong?
Thanks in advance for the help


 
Reply With Quote
 
 
 
 
ranganh
Guest
Posts: n/a
 
      06-12-2004
Dear Karen,

After you do the DataBind, set the default value as 0 or 1 dependign upon your requirement.

RadioButtonList.SelectedIndex = 0; (or 1 if you want 1 to be selected as default)

that will ensure the radiobutton list is not left unchecked.

one suggestion, if there are only 2 values, you dont need a radiobuttonlist, you can very well go for the radiobutton and set the default property by allowing checked=true

hope it helps.



"Karen A Hodge" wrote:

> I have a RadioButtonList on my form. There are only two items in the
> collection, "No" = 0, and "Yes" = 1. I have the SelectedIndex property bound
> to a SQL Server table which has a column of datatype, bit. The default value
> is zero for that column. I expect that after the databinding occurs, any
> value of 1 would have "Yes" selected and that 0 would have "No" selected,
> instead, neither are selected as if the selected index were -1.
> What am I doing wrong?
> Thanks in advance for the help
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lower bound & Upper bound sunil panda Java 9 10-07-2008 08:32 PM
Passing Bound Object value to another Bound Object Phillip Vong ASP .Net 0 07-27-2006 10:54 PM
How to represent the data in a not bound control via bound control Mario Krsnic ASP .Net 0 06-23-2006 07:38 AM
Getting lower-bound and upper-bound of strings input Rhiner Dan C++ 1 03-27-2005 02:03 AM
Losing state on bound controls in user controls Josh ASP .Net 1 03-23-2005 03:23 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57