radiobuttonlist property

vbnetrookie

Member
Joined
May 30, 2005
Messages
5
Programming Experience
Beginner
Hello dear developpers!!


I'm building a web app(form) in which I have 2 radiobuttonlist, the
second one only appears when a certain item is selected from the first
one. And afterwards, I send the selected item as a string and into a
database table. This works fine when the second radiobuttonlist appears
and an option is selected. The problem arises when the second
rbl(radiobuttonlist) doesn't appear because the specific item wasn't
selected, (which is alrigh) but when I click my submit button...I get
an error saying :


Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.


So I would like to assign a value by default to the second rbl
something like Null...
I tried RadioButtonList2.Items.Add("Nu­ll")


but it still gives me the error, and i guess it's 'cause that item
isn't really selected...it's just added to the list...


does anyone know a way of assigning a value by default to a component
that isn't even visible on the page at that time ???


Thanks for the help guys!!!
JMT
 
Hi,
If you are using radiobuttonlist, then you might be inserting either radiobuttonlist1 values or radiobuttonlist2 values.

You might be getting the null reference exception due to the insert statement. Build your insert statement dynamically based on the selected values. Then you will not get. Here I have done a small prog on this.
Hope this might be useful to u.

Good Luck
Reshma
 

Attachments

  • ListApp.zip
    3.5 KB · Views: 107
Back
Top