Ask a Question related to ASP.NET General, Design and Development.
-
Hazzard #1
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
Hazzard Guest
-
Populating Drop Down Boxes from a database
We moved our wesite from a Box running Coldfusion 4.0 to a box running Coldfusion MX. We populate some drop down boxes with information from a... -
Web Form Populating Database
Publisher 2003. Web form set to save the data in a comma-delimeted text file on my web server. Form working well, I'm able to use the wizard in... -
populating text from database
I am trying to populate multiple textboxes from an Access database. I am trying to write code to generate the appropriate number of textboxes... -
Populating three list boxes from the database
Can anybody help? I need to have three list boxes automatically populating each other, (ie when region is selected from the first listbox, it will... -
Populating another database with records from an asp page.
Apologies for the length of this mail but code is included. Have a page that pulls data from one database & displays the results, using a loop to... -
Hazzard #2
Re: populating radiobuttonlist from database programmatically
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" <gengoj@krause.com> wrote in message
news:vh5cqv4utha44@corp.supernews.com...don't> Hazzard,
>
> Have you tried:
>
> RadioButtonList.SelectedIndex = -1
>
> I hope this helps.
>
> Justin
>
>
> "Hazzard" <hazz@sonic.net> wrote in message
> news:uYZa2fgSDHA.1688@TK2MSFTNGP11.phx.gbl...> radio> > I store radiobuttonlist values in the db using the string value of the> reuse> > button item value. (nvarchar)
> >
> > I am creating an edit functionality on the asp.net form so that when I> the> > my dataentry form for edit, I search the database for the row containing> where> > 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> > a dirty database has no associated value for the radiobuttonlist, Ireturned> > want to select anything. How do I do that?
> > ***************
> > dbaseReturnValue = arParms(17).Value.ToString() 'get value fromis> > stored procedure call.
> > For Each li In RadioButtonList.Items
> > i += 1
> > If (RadioButtonList.Value = dbaseReturnValue Then //but Value>> > not a valid member. what do i use?
> > RadioButtonList.SelectedValue = dbaseReturnValue
> > li.Selected = True
> > else
> > RadioButtonList.SelectedValue = ???????????
> > End If
> > Next
> > ***************
> > Thank you,
> > Greg Hazzard
> >
> >
>
Hazzard Guest
-
S. Justin Gengo #3
Re: populating radiobuttonlist from database programmatically
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" <hazz@sonic.net> wrote in message
news:OtT7vShSDHA.1684@TK2MSFTNGP11.phx.gbl...the> Thank you Justin ! Of course, it sets it to a value out of the range of"radiobuttonvalue1"> valid values.
> And what about the comparison of the database value, eg.containing> ?
> 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" <gengoj@krause.com> wrote in message
> news:vh5cqv4utha44@corp.supernews.com...> > Hazzard,
> >
> > Have you tried:
> >
> > RadioButtonList.SelectedIndex = -1
> >
> > I hope this helps.
> >
> > Justin
> >
> >
> > "Hazzard" <hazz@sonic.net> wrote in message
> > news:uYZa2fgSDHA.1688@TK2MSFTNGP11.phx.gbl...> > radio> > > I store radiobuttonlist values in the db using the string value of the> > reuse> > > button item value. (nvarchar)
> > >
> > > I am creating an edit functionality on the asp.net form so that when I> > > my dataentry form for edit, I search the database for the rowValue> don't> > the> > where> > > 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> > > a dirty database has no associated value for the radiobuttonlist, I> returned> > > want to select anything. How do I do that?
> > > ***************
> > > dbaseReturnValue = arParms(17).Value.ToString() 'get value from> > > stored procedure call.
> > > For Each li In RadioButtonList.Items
> > > i += 1
> > > If (RadioButtonList.Value = dbaseReturnValue Then //but> 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
> > >
> > >
> >
>
S. Justin Gengo Guest
-
Hazzard #4
Re: populating radiobuttonlist from database programmatically
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" <gengoj@krause.com> wrote in message
news:vh5hh645ojc86e@corp.supernews.com...the> 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" <hazz@sonic.net> wrote in message
> news:OtT7vShSDHA.1684@TK2MSFTNGP11.phx.gbl...> the> > Thank you Justin ! Of course, it sets it to a value out of the range of> "radiobuttonvalue1"> > valid values.
> > And what about the comparison of the database value, eg.> > ?
> > 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" <gengoj@krause.com> wrote in message
> > news:vh5cqv4utha44@corp.supernews.com...> > > Hazzard,
> > >
> > > Have you tried:
> > >
> > > RadioButtonList.SelectedIndex = -1
> > >
> > > I hope this helps.
> > >
> > > Justin
> > >
> > >
> > > "Hazzard" <hazz@sonic.net> wrote in message
> > > news:uYZa2fgSDHA.1688@TK2MSFTNGP11.phx.gbl...
> > > > I store radiobuttonlist values in the db using the string value ofI> > > radio
> > > > button item value. (nvarchar)
> > > >
> > > > I am creating an edit functionality on the asp.net form so that whencases> containing> > > reuse
> > > > my dataentry form for edit, I search the database for the row> > > 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> Value> > don't> > > where
> > > > a dirty database has no associated value for the radiobuttonlist, I> > returned> > > > want to select anything. How do I do that?
> > > > ***************
> > > > dbaseReturnValue = arParms(17).Value.ToString() 'get value from> > > > stored procedure call.
> > > > For Each li In RadioButtonList.Items
> > > > i += 1
> > > > If (RadioButtonList.Value = dbaseReturnValue Then //but>> > 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
> > > >
> > > >
> > >
> > >
> >
>
Hazzard Guest



Reply With Quote

