473,289 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

setting the selected value of radiobutton list from database value

I am trying to set the selected value of a radio button list from a
value stored in a table of a database. using vb codebehind asp.net. I
tried binding the selected index item and selected index value to the
dataset field for the selected line item. This is on a details page.
When I do this I get an Index 0 value error.

My goal it to have the radiobutton selected yes if the database value
is yes ect.

Thanks for the help.

May 13 '06 #1
1 12077
K B
Since you show no code, let's assume you populate your radionbutton list
(rblTest) as such:

Value Text
1 Yes
2 No

or whatever values you're using.

Also assuming you store the Value in your database and not the text, you
retrieve your value, for example, as
Dim iValue as Integer = ds.Tables(0).Rows(0)("ButtonValue")

To select the correct radio button you would do:

rblTest.SelectedValue = iValue (either 1 or 2)

If you're storing Yes/No as text in the value field, then use
rblText.SelectedItem.Text = sValue (Yes or No).

The index item is not involved here...only Value or Text.

HTH,
Kit

*** Sent via Developersdex http://www.developersdex.com ***
May 14 '06 #2

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

Similar topics

1
by: Empire City | last post by:
I have an ASP.NET form with a DataGrid and Button. I want to put a RadioButtonList in a DataGrid cell. I bind it to an ArrayList which has a ListItem in the cell. The display part works fine. I...
3
by: Janaka | last post by:
I've seen and used some samples where you can set the onclick attrubute to a Button control to get it to do some javascript a la : btnUse.Attributes = "DoSomeJS()"; However when i try and get...
4
by: darrel | last post by:
I have a contact form that a person submits to the server. In ASP, you'd make a page, post the form to another page, which would grab the values and do somethign with them. in ASP.NET, it...
2
by: Martin | last post by:
Hi, Please can somebody explain how databinding is done on a checkbox list. I have the follwoing code which I would have thought was enough to databind a checkbox, but apparently not. The...
8
by: tshad | last post by:
I have a string that I read from my database: 1|8|5620|541 These are all values in my ListBox. I want to select each of these items (4 of them - but could be many more). At the moment I am...
0
by: LCAdeveloper | last post by:
Another newbie question I'm afraid. When I use the .Focus() or .Select() methods to set the initial control that has focus on a form, try as I might I cannot get the control to visually indicate...
2
by: comerica1 | last post by:
I have the basic structure as follows: 2 drop downs A & B. A is populated using (datasource methods - from database). B is poulated using A's selected value as input and retrieve the list...
1
by: Vinnie | last post by:
i have a radiobutton list, and one label with a textbox. Beside the Texbox i have inserted a fieldvalidator: now, i was wondering if the code that follows is correct, and if it does, where i should...
1
by: dmj07 | last post by:
Hi all, I was wondering of an easy way to set the selected value of a drop down list by using a value retrieved from the database. Here is my code: SqlCommand cmdUser = new...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.