Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Data Bound Controls (http://www.velocityreviews.com/forums/t773524-data-bound-controls.html)

Karen A Hodge 06-12-2004 11:09 AM

Data Bound Controls
 
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



ranganh 06-12-2004 03:31 PM

RE: Data Bound Controls
 
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
>
>
>



All times are GMT. The time now is 02:48 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.