selected then get the value.. This was my code;
--------------------
Dim NewGender as String
if (Gender.SelectedItem.Value <> "") then
NewGender = Gender.SelectedItem.Value
else
NewGender = ""
end if
If nothing is selected, I get the following error..
System.NullReferenceException: Object reference not set to an instance
of an object.
thank in advance..Yes, if no item is selected then you get the error. Wouldn't you expect to
get it if you are checking the Value property of SelectedItem, but
SelectedItem is null?
What is your question exactly?
"Brian" <bciarcia@.pepehazard.com> wrote in message
news:1112200428.271311.212350@.l41g2000cwc.googlegr oups.com...
>i have a radiobuttonlist. I want to check to see if a button has been
> selected then get the value.. This was my code;
> --------------------
> Dim NewGender as String
> if (Gender.SelectedItem.Value <> "") then
> NewGender = Gender.SelectedItem.Value
> else
> NewGender = ""
> end if
> If nothing is selected, I get the following error..
> System.NullReferenceException: Object reference not set to an instance
> of an object.
> thank in advance..
I needed to check if there was a value or not, so I wouldn't get an
error when I posted the value..
I figured it out though.. i needed to to Gender.SelectedValue.. I am
kinda new to this, so I am still learning.. Thanks for your response..
*** Sent via Developersdex http://www.developersdex.com ***
Hi Brian,
1. You can set a default value for radiobuttonlist.
2. Or you can
If Not Gender.SelectedItem Is Nothing Then
if (Gender.SelectedItem.Value <> "") then
' ...
End If
HTH
Elton Wang
elton_wang@.hotmail.com
>--Original Message--
>i have a radiobuttonlist. I want to check to see if a
button has been
>selected then get the value.. This was my code;
>------------------
--
>Dim NewGender as String
>if (Gender.SelectedItem.Value <> "") then
>NewGender = Gender.SelectedItem.Value
>else
>NewGender = ""
>end if
>If nothing is selected, I get the following error..
>System.NullReferenceException: Object reference not set
to an instance
>of an object.
>thank in advance..
>.
Brian,
I've been doing some research on radiobuttonlists and from what i've read
and the examples i've looked at, i have not yet found a way to handle an
"unselected" radiobuttonlist.
Are you trying to update a database or just trying to display what the user
has selected?
Also, i'd be interested to know if you have found a way to update a
database (even if it's a null value) if no items in a radiobuttonlist have
been selected.
Thanks.
--
Message posted via http://www.dotnetmonster.com
0 comments:
Post a Comment