By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,569 Members | 1,422 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,569 IT Pros & Developers. It's quick & easy.

populating radiobuttonlist from database programmatically

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.