with a table with 2 fields, 'areaID' and 'areaName'.
in the Data properties window of the DDL, i have the DataTextField set
to areaName, and the DataValueField set to areaID.
when an item is selected from the DDL i need the areaName to go in one
textbox and areaID to go in another.
this line to get the areaName works fine:
TextBox1.Text = DropDownList1.SelectedValue
but when i try get the areaID field:
TextBox1.Text = DropDownList1.SelectedItem.Text
i get the following error:
Object reference not set to an instance of an object.
can anyone tell me what exactly this error means and how to fix it
please? my head is wrecked from this.The message means one of the values participating in the statement is null.
Set a breakpoint on the line and see which value is null.
Eliyahu
<somersbar@.yahoo.com> wrote in message
news:1142956097.198040.293670@.i40g2000cwc.googlegr oups.com...
>i have a webform with a dropdownlist and 2 textboxes. it has a dataset
> with a table with 2 fields, 'areaID' and 'areaName'.
> in the Data properties window of the DDL, i have the DataTextField set
> to areaName, and the DataValueField set to areaID.
> when an item is selected from the DDL i need the areaName to go in one
> textbox and areaID to go in another.
> this line to get the areaName works fine:
> TextBox1.Text = DropDownList1.SelectedValue
> but when i try get the areaID field:
> TextBox1.Text = DropDownList1.SelectedItem.Text
> i get the following error:
> Object reference not set to an instance of an object.
> can anyone tell me what exactly this error means and how to fix it
> please? my head is wrecked from this.
0 comments:
Post a Comment