473,397 Members | 2,028 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,397 software developers and data experts.

populating radiobuttonlist from database programmatically

I store radiobuttonlist values in the db using the string value of the radio
button item value. (nvarchar)

I am creating an edit functionality on the asp.net form so that when I reuse
my dataentry form for edit, I search the database for the row containing the
data I want, and then populate all the form fields.

here is what I have so far. What I don't know what to do is for cases where
a dirty database has no associated value for the radiobuttonlist, I don't
want to select anything. How do I do that?
***************
dbaseReturnValue = arParms(17).Value.ToString() 'get value from returned
stored procedure call.
For Each li In RadioButtonList.Items
i += 1
If (RadioButtonList.Value = dbaseReturnValue Then //but Value is
not a valid member. what do i use?
RadioButtonList.SelectedValue = dbaseReturnValue
li.Selected = True
else
RadioButtonList.SelectedValue = ???????????
End If
Next
***************
Thank you,
Greg Hazzard
Nov 17 '05 #1
6 5633
Thank you Justin ! Of course, it sets it to a value out of the range of the
valid values.
And what about the comparison of the database value, eg. "radiobuttonvalue1"
?
Which property do I use to iterate through the list of radiobutton item
values to compare with say, "radiobuttonvalue1?" Is it
radionbuttonlist.items.??? or
radiobutton.items.searchbyvalue("radiobuttonvalue1 ")..

thank you,
Greg

"S. Justin Gengo" <ge****@krause.com> wrote in message
news:vh***********@corp.supernews.com...
Hazzard,

Have you tried:

RadioButtonList.SelectedIndex = -1

I hope this helps.

Justin
"Hazzard" <ha**@sonic.net> wrote in message
news:uY**************@TK2MSFTNGP11.phx.gbl...
I store radiobuttonlist values in the db using the string value of the

radio
button item value. (nvarchar)

I am creating an edit functionality on the asp.net form so that when I

reuse
my dataentry form for edit, I search the database for the row containing

the
data I want, and then populate all the form fields.

here is what I have so far. What I don't know what to do is for cases

where
a dirty database has no associated value for the radiobuttonlist, I don't want to select anything. How do I do that?
***************
dbaseReturnValue = arParms(17).Value.ToString() 'get value from returned stored procedure call.
For Each li In RadioButtonList.Items
i += 1
If (RadioButtonList.Value = dbaseReturnValue Then //but Value is not a valid member. what do i use?
RadioButtonList.SelectedValue = dbaseReturnValue
li.Selected = True
else
RadioButtonList.SelectedValue = ???????????
End If
Next
***************
Thank you,
Greg Hazzard


Nov 17 '05 #2
Thank you Justin ! Of course, it sets it to a value out of the range of the
valid values.
And what about the comparison of the database value, eg. "radiobuttonvalue1"
?
Which property do I use to iterate through the list of radiobutton item
values to compare with say, "radiobuttonvalue1?" Is it
radionbuttonlist.items.??? or
radiobutton.items.searchbyvalue("radiobuttonvalue1 ")..

thank you,
Greg

"S. Justin Gengo" <ge****@krause.com> wrote in message
news:vh***********@corp.supernews.com...
Hazzard,

Have you tried:

RadioButtonList.SelectedIndex = -1

I hope this helps.

Justin
"Hazzard" <ha**@sonic.net> wrote in message
news:uY**************@TK2MSFTNGP11.phx.gbl...
I store radiobuttonlist values in the db using the string value of the

radio
button item value. (nvarchar)

I am creating an edit functionality on the asp.net form so that when I

reuse
my dataentry form for edit, I search the database for the row containing

the
data I want, and then populate all the form fields.

here is what I have so far. What I don't know what to do is for cases

where
a dirty database has no associated value for the radiobuttonlist, I don't want to select anything. How do I do that?
***************
dbaseReturnValue = arParms(17).Value.ToString() 'get value from returned stored procedure call.
For Each li In RadioButtonList.Items
i += 1
If (RadioButtonList.Value = dbaseReturnValue Then //but Value is not a valid member. what do i use?
RadioButtonList.SelectedValue = dbaseReturnValue
li.Selected = True
else
RadioButtonList.SelectedValue = ???????????
End If
Next
***************
Thank you,
Greg Hazzard


Nov 17 '05 #3
Greg,

'---This code seems like more work but I've found it to be the fastest way
to iterate

' through a loop because it calls on less objects

Dim ItemCount, ItemLoop As Int32

ItemCount = RadioButtonList.Items.Count - 1

For ItemLoop = 0 To ItemCount

If RadioButtonList.Items(ItemLoop).Value = dbaseReturnValue Then

RadioButtonList.SelectedIndex = ItemLoop

Exit For

End If

Next

Justin

"Hazzard" <ha**@sonic.net> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
Thank you Justin ! Of course, it sets it to a value out of the range of the valid values.
And what about the comparison of the database value, eg. "radiobuttonvalue1" ?
Which property do I use to iterate through the list of radiobutton item
values to compare with say, "radiobuttonvalue1?" Is it
radionbuttonlist.items.??? or
radiobutton.items.searchbyvalue("radiobuttonvalue1 ")..

thank you,
Greg

"S. Justin Gengo" <ge****@krause.com> wrote in message
news:vh***********@corp.supernews.com...
Hazzard,

Have you tried:

RadioButtonList.SelectedIndex = -1

I hope this helps.

Justin
"Hazzard" <ha**@sonic.net> wrote in message
news:uY**************@TK2MSFTNGP11.phx.gbl...
I store radiobuttonlist values in the db using the string value of the radio
button item value. (nvarchar)

I am creating an edit functionality on the asp.net form so that when I

reuse
my dataentry form for edit, I search the database for the row
containing
the
data I want, and then populate all the form fields.

here is what I have so far. What I don't know what to do is for cases

where
a dirty database has no associated value for the radiobuttonlist, I

don't want to select anything. How do I do that?
***************
dbaseReturnValue = arParms(17).Value.ToString() 'get value from returned stored procedure call.
For Each li In RadioButtonList.Items
i += 1
If (RadioButtonList.Value = dbaseReturnValue Then //but
Value is not a valid member. what do i use?
RadioButtonList.SelectedValue = dbaseReturnValue
li.Selected = True
else
RadioButtonList.SelectedValue = ???????????
End If
Next
***************
Thank you,
Greg Hazzard



Nov 17 '05 #4
Greg,

'---This code seems like more work but I've found it to be the fastest way
to iterate

' through a loop because it calls on less objects

Dim ItemCount, ItemLoop As Int32

ItemCount = RadioButtonList.Items.Count - 1

For ItemLoop = 0 To ItemCount

If RadioButtonList.Items(ItemLoop).Value = dbaseReturnValue Then

RadioButtonList.SelectedIndex = ItemLoop

Exit For

End If

Next

Justin

"Hazzard" <ha**@sonic.net> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
Thank you Justin ! Of course, it sets it to a value out of the range of the valid values.
And what about the comparison of the database value, eg. "radiobuttonvalue1" ?
Which property do I use to iterate through the list of radiobutton item
values to compare with say, "radiobuttonvalue1?" Is it
radionbuttonlist.items.??? or
radiobutton.items.searchbyvalue("radiobuttonvalue1 ")..

thank you,
Greg

"S. Justin Gengo" <ge****@krause.com> wrote in message
news:vh***********@corp.supernews.com...
Hazzard,

Have you tried:

RadioButtonList.SelectedIndex = -1

I hope this helps.

Justin
"Hazzard" <ha**@sonic.net> wrote in message
news:uY**************@TK2MSFTNGP11.phx.gbl...
I store radiobuttonlist values in the db using the string value of the radio
button item value. (nvarchar)

I am creating an edit functionality on the asp.net form so that when I

reuse
my dataentry form for edit, I search the database for the row
containing
the
data I want, and then populate all the form fields.

here is what I have so far. What I don't know what to do is for cases

where
a dirty database has no associated value for the radiobuttonlist, I

don't want to select anything. How do I do that?
***************
dbaseReturnValue = arParms(17).Value.ToString() 'get value from returned stored procedure call.
For Each li In RadioButtonList.Items
i += 1
If (RadioButtonList.Value = dbaseReturnValue Then //but
Value is not a valid member. what do i use?
RadioButtonList.SelectedValue = dbaseReturnValue
li.Selected = True
else
RadioButtonList.SelectedValue = ???????????
End If
Next
***************
Thank you,
Greg Hazzard



Nov 17 '05 #5
Thank you Justin! It even floats over a dirty database. Clean algorithm.
_greg
************************************
arReturnParms(x) = arParms(x).Value.ToString() 'value returned from
database stored procedure.
RadioButtonList.SelectedIndex = -1 'no radio buttons
checked
ItemCount = RadioButtonList.Items.Count - 1
For ItemLoop = 0 To ItemCount
If RadioButtonList.Items(ItemLoop).Value = arReturnParms(x) Then
'unless there is a match
RadioButtonList.SelectedIndex = ItemLoop
Exit For
End If
Next
******************************

"S. Justin Gengo" <ge****@krause.com> wrote in message
news:vh************@corp.supernews.com...
Greg,

'---This code seems like more work but I've found it to be the fastest way
to iterate

' through a loop because it calls on less objects

Dim ItemCount, ItemLoop As Int32

ItemCount = RadioButtonList.Items.Count - 1

For ItemLoop = 0 To ItemCount

If RadioButtonList.Items(ItemLoop).Value = dbaseReturnValue Then

RadioButtonList.SelectedIndex = ItemLoop

Exit For

End If

Next

Justin

"Hazzard" <ha**@sonic.net> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
Thank you Justin ! Of course, it sets it to a value out of the range of

the
valid values.
And what about the comparison of the database value, eg.

"radiobuttonvalue1"
?
Which property do I use to iterate through the list of radiobutton item
values to compare with say, "radiobuttonvalue1?" Is it
radionbuttonlist.items.??? or
radiobutton.items.searchbyvalue("radiobuttonvalue1 ")..

thank you,
Greg

"S. Justin Gengo" <ge****@krause.com> wrote in message
news:vh***********@corp.supernews.com...
Hazzard,

Have you tried:

RadioButtonList.SelectedIndex = -1

I hope this helps.

Justin
"Hazzard" <ha**@sonic.net> wrote in message
news:uY**************@TK2MSFTNGP11.phx.gbl...
> I store radiobuttonlist values in the db using the string value of the radio
> button item value. (nvarchar)
>
> I am creating an edit functionality on the asp.net form so that when I reuse
> my dataentry form for edit, I search the database for the row containing the
> data I want, and then populate all the form fields.
>
> here is what I have so far. What I don't know what to do is for cases where
> a dirty database has no associated value for the radiobuttonlist, I

don't
> want to select anything. How do I do that?
> ***************
> dbaseReturnValue = arParms(17).Value.ToString() 'get value from

returned
> stored procedure call.
> For Each li In RadioButtonList.Items
> i += 1
> If (RadioButtonList.Value = dbaseReturnValue Then //but

Value
is
> not a valid member. what do i use?
> RadioButtonList.SelectedValue = dbaseReturnValue
> li.Selected = True
> else
> RadioButtonList.SelectedValue = ???????????
> End If
> Next
> ***************
> Thank you,
> Greg Hazzard
>
>



Nov 17 '05 #6
Thank you Justin! It even floats over a dirty database. Clean algorithm.
_greg
************************************
arReturnParms(x) = arParms(x).Value.ToString() 'value returned from
database stored procedure.
RadioButtonList.SelectedIndex = -1 'no radio buttons
checked
ItemCount = RadioButtonList.Items.Count - 1
For ItemLoop = 0 To ItemCount
If RadioButtonList.Items(ItemLoop).Value = arReturnParms(x) Then
'unless there is a match
RadioButtonList.SelectedIndex = ItemLoop
Exit For
End If
Next
******************************

"S. Justin Gengo" <ge****@krause.com> wrote in message
news:vh************@corp.supernews.com...
Greg,

'---This code seems like more work but I've found it to be the fastest way
to iterate

' through a loop because it calls on less objects

Dim ItemCount, ItemLoop As Int32

ItemCount = RadioButtonList.Items.Count - 1

For ItemLoop = 0 To ItemCount

If RadioButtonList.Items(ItemLoop).Value = dbaseReturnValue Then

RadioButtonList.SelectedIndex = ItemLoop

Exit For

End If

Next

Justin

"Hazzard" <ha**@sonic.net> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
Thank you Justin ! Of course, it sets it to a value out of the range of

the
valid values.
And what about the comparison of the database value, eg.

"radiobuttonvalue1"
?
Which property do I use to iterate through the list of radiobutton item
values to compare with say, "radiobuttonvalue1?" Is it
radionbuttonlist.items.??? or
radiobutton.items.searchbyvalue("radiobuttonvalue1 ")..

thank you,
Greg

"S. Justin Gengo" <ge****@krause.com> wrote in message
news:vh***********@corp.supernews.com...
Hazzard,

Have you tried:

RadioButtonList.SelectedIndex = -1

I hope this helps.

Justin
"Hazzard" <ha**@sonic.net> wrote in message
news:uY**************@TK2MSFTNGP11.phx.gbl...
> I store radiobuttonlist values in the db using the string value of the radio
> button item value. (nvarchar)
>
> I am creating an edit functionality on the asp.net form so that when I reuse
> my dataentry form for edit, I search the database for the row containing the
> data I want, and then populate all the form fields.
>
> here is what I have so far. What I don't know what to do is for cases where
> a dirty database has no associated value for the radiobuttonlist, I

don't
> want to select anything. How do I do that?
> ***************
> dbaseReturnValue = arParms(17).Value.ToString() 'get value from

returned
> stored procedure call.
> For Each li In RadioButtonList.Items
> i += 1
> If (RadioButtonList.Value = dbaseReturnValue Then //but

Value
is
> not a valid member. what do i use?
> RadioButtonList.SelectedValue = dbaseReturnValue
> li.Selected = True
> else
> RadioButtonList.SelectedValue = ???????????
> End If
> Next
> ***************
> Thank you,
> Greg Hazzard
>
>



Nov 17 '05 #7

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

Similar topics

0
by: Hazzard | last post by:
I store radiobuttonlist values in the db using the string value of the radio button item value. (nvarchar) I am creating an edit functionality on the asp.net form so that when I reuse my...
1
by: Christian H | last post by:
Hi! I'm wondering how I can add extra html to a radiobuttonList, so that I can control how: -the whole radioButtonList is rendered. -each of the radiobutton elements are rendered. What I am...
5
by: DotNetGruven | last post by:
Anyone have any pointers on how to set the Value and Selected attributes in a ListItem in a RadioButtonList that is in a DataGrid? Here's what I have ------DataGrid------ -- BoundColumn 0 --...
6
by: DotNetGruven | last post by:
I have a webform that has a DataGrid on it with a RadioButtonList in each row. It is a simple On & Off. When the User Clicks on either of the RadioButtons, I need to postback to the server and...
2
by: Michael Bohman | last post by:
Hi, i have a small problem with assigning a database value to a RadioButtonList control. On my form i have 3 user admin=1, premium=2 and basic=3, theese values is stored in an access database in a...
3
by: standon410 | last post by:
Hi, I'm trying to develop a questionnaire...basically a user can pick one of 5 questionnaires they want to use, and based on their choice, those questions will appear in their form. So the...
0
by: frankiefrank | last post by:
Hello, I have an aspx page with a RadioButtonList that has two Items, and a "ComboBox" (DropDownList) that I want to populate based on the selection in the RadioButtonList. The first...
4
by: axapta | last post by:
How can I programmatically change the selected item within the above control. I only have 2 items within it and I want to set the default (programmatically) to item 1. I've tried...
13
by: tommymo | last post by:
Hi everyone I'm new to this site and the world of ASP.Net C# programming. I have been learning controls and integrating them with a SQL database. So far I have been able to move along and understand...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.