473,513 Members | 2,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

radioList

I have a radioList on my web form that has to be checked based on a data item
from my database, how can I check one of the radio buttons in the list?

example: my data is returned 1, 2, 3
and in my list I need to one of them checked based on the number returned?
how can i do that in .net?

Feb 3 '06 #1
5 1564
Well, I am more Vb .net but my guess would be.... when you know the value you
returned from the database... I then say... rbList.selectedValue = your
database value.

"CsharpGuy" wrote:
I have a radioList on my web form that has to be checked based on a data item
from my database, how can I check one of the radio buttons in the list?

example: my data is returned 1, 2, 3
and in my list I need to one of them checked based on the number returned?
how can i do that in .net?

Feb 3 '06 #2
I tried that and it didn't work, i also did

case (modelNumber)
{
case "0":
radio.selectedItem.selected = true;
break;
case "525":
radio.selectedItem.selected = true;
}

and I get

Object reference not set to an instance of an object and it goes to this line:
radio.selectedItem.selected = true;
"MrsLeigh" wrote:
Well, I am more Vb .net but my guess would be.... when you know the value you
returned from the database... I then say... rbList.selectedValue = your
database value.

"CsharpGuy" wrote:
I have a radioList on my web form that has to be checked based on a data item
from my database, how can I check one of the radio buttons in the list?

example: my data is returned 1, 2, 3
and in my list I need to one of them checked based on the number returned?
how can i do that in .net?

Feb 3 '06 #3
It sounds like it may be an event order problem and the control has not yet
been rendered when you try to set the property.

Have you tried casting a control in the ItemDataBound or ItemCreated event,
then setting its property?

"CsharpGuy" <Cs*******@discussions.microsoft.com> wrote in message
news:4E**********************************@microsof t.com...
I tried that and it didn't work, i also did

case (modelNumber)
{
case "0":
radio.selectedItem.selected = true;
break;
case "525":
radio.selectedItem.selected = true;
}

and I get

Object reference not set to an instance of an object and it goes to this
line:
radio.selectedItem.selected = true;
"MrsLeigh" wrote:
Well, I am more Vb .net but my guess would be.... when you know the value
you
returned from the database... I then say... rbList.selectedValue = your
database value.

"CsharpGuy" wrote:
> I have a radioList on my web form that has to be checked based on a
> data item
> from my database, how can I check one of the radio buttons in the list?
>
> example: my data is returned 1, 2, 3
> and in my list I need to one of them checked based on the number
> returned?
> how can i do that in .net?
>

Feb 3 '06 #4
Assuming modelNumber is an Integer datatype (or cast to one):

'RadioButtonList has a zero-based index for items
me.myRadioList.SelectedIndex = cint(modelNumber)

Hope that helps.

Al

"CsharpGuy" <Cs*******@discussions.microsoft.com> wrote in message
news:4E**********************************@microsof t.com...
I tried that and it didn't work, i also did

case (modelNumber)
{
case "0":
radio.selectedItem.selected = true;
break;
case "525":
radio.selectedItem.selected = true;
}

and I get

Object reference not set to an instance of an object and it goes to this
line:
radio.selectedItem.selected = true;
"MrsLeigh" wrote:
Well, I am more Vb .net but my guess would be.... when you know the value
you
returned from the database... I then say... rbList.selectedValue = your
database value.

"CsharpGuy" wrote:
> I have a radioList on my web form that has to be checked based on a
> data item
> from my database, how can I check one of the radio buttons in the list?
>
> example: my data is returned 1, 2, 3
> and in my list I need to one of them checked based on the number
> returned?
> how can i do that in .net?
>

Feb 4 '06 #5
I got it to bind correctly, but now if the user changes it on the page its
still reading the default value.

example:

if the pages loads and radiobutton #2 is selected and I make a change and
select radiobutton #3, it still reads it as checkbox #2 is selected, so how
can i get the value of the correct radiobutton that is selected

"Elliot Rodriguez" wrote:
It sounds like it may be an event order problem and the control has not yet
been rendered when you try to set the property.

Have you tried casting a control in the ItemDataBound or ItemCreated event,
then setting its property?

"CsharpGuy" <Cs*******@discussions.microsoft.com> wrote in message
news:4E**********************************@microsof t.com...
I tried that and it didn't work, i also did

case (modelNumber)
{
case "0":
radio.selectedItem.selected = true;
break;
case "525":
radio.selectedItem.selected = true;
}

and I get

Object reference not set to an instance of an object and it goes to this
line:
radio.selectedItem.selected = true;
"MrsLeigh" wrote:
Well, I am more Vb .net but my guess would be.... when you know the value
you
returned from the database... I then say... rbList.selectedValue = your
database value.

"CsharpGuy" wrote:

> I have a radioList on my web form that has to be checked based on a
> data item
> from my database, how can I check one of the radio buttons in the list?
>
> example: my data is returned 1, 2, 3
> and in my list I need to one of them checked based on the number
> returned?
> how can i do that in .net?
>


Feb 4 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
826
by: Celebrate | last post by:
Does anyone know how to get rid of the thin box that is drawn around a radio button (Web control) in ASP.NET? Thanks ahead of time, Paul Leury
2
6536
by: headware | last post by:
How can I disable a single radio button in a RadioButtonList? I tried doing this: radioList.Items.Attributes.Add("disabled", "true"); radioList.Items.Attributes.Add("disabled", "true"); but it...
0
1204
by: Do | last post by:
Is this the correct syntax? I'm missing something about the list items, but I don't know where to find it. CType(e.Item.FindControl("lstEUsertype"), ListBox).SelectedValue() = "E" I want to...
0
939
by: Random | last post by:
I'm working with Whidbey (ASP.NET 2.0), and still getting familiar with the new DataSource controls and methods of databinding. I have a databinding conundrum that I am wondering how is best...
2
1139
by: CsharpGuy | last post by:
I have a radioList with 3 radio buttons in it. The buttons are seleced based off of the data coming back from SQL. On my web form the user can change the radio button selection. Now, when the user...
2
2212
by: DataSmash | last post by:
Hello, I've created a simple form with 2 radio boxes, 2 text boxes and a button. When I click the button, I'd like to write each "choice" to a text file. I can't figure out how to "link" the...
26
2295
by: the.tarquin | last post by:
Okay, this one has me totally baffled. I have a function, getParsedKey(char* key, char* returnString). I pass in the key I want, it retrieves it from a data structure and puts the value in...
1
1241
by: mercea | last post by:
Hi all, i have a web page which contains a gridview. On this gridview, the user uses a set of radiobuttonlists to select an option. the selected option is then to be compared with the data in a...
4
2159
by: gsaray101 | last post by:
I have an asp.net page that has one radiolist (called lstcheck) and one checkboxlist (call lstExchange). Depending on the which radiolist item is checked, I need to clear the checkbox list or check...
0
7267
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7553
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4754
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3247
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3235
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1609
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
466
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.