Object reference not set to an instance of an object.

S

somersbar

i have a dropdownlist and 2 textbox's on my webform.
i have a table 'Areas', with 2 fields in the dataset.

In the Data properties of the DDL i have its DataTextField set to the
field 'areaName', and its DataValueField set to the other field
'areaID'.

When i select an item from the DDL i want the 'areaName' to go into
textBox1 and the 'areaID' to go into textbox2.

when i try get the the selected value:
TextBox1.Text = DropDownList1.SelectedValue
which works, gives me the areaName.

however when i try get the other field, areaID :
TextBox2.Text = DropDownList1.SelectedItem.Text
i get the error :
Object reference not set to an instance of an object.

can anyone tell me what exactly this error means, please?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top