thx for the reply.
In the database there is no CompanyID with the value "0" but i'm using the
SelectedItem.value to populate the Data 'm displaying
I have i.e
If Not Page.IsPostBack Then
GetCompany()
End If
And in the Sub:-
objDR = Cmd.ExecuteReader(System.Data.CommandBehavior.Clos eConnection)
ddlcompany.DataSource = objDR
ddlcompany.DataValueField = "CompanyID"
ddlcompany.DataTextField = "CompanyName"
ddlcompany.DataBind()
' i get the error after first selecting the other optrions
and then select the "-- Select Company --"
ddlcompany.Items.Insert(0, "-- Select Company --")
"Onin Tayson" <Le*********@compaid.com> wrote in message
news:uv**************@TK2MSFTNGP15.phx.gbl...
Hi Pat,
Can you show some code snippets? Do you check for IsPostBack property
before population of your DropDownList? You might be rebuilding the DDL
every PostBack.
HTH,
"Pat" <na********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl... When selecting a DropDownlList to display some Data based on the
ddl.SelectedItem.Value
since a dropdownlist index starts from 0..
After selecting for example value1 and 2 which its ok but when you get
back
to select 0
it gives an error "Object reference not set to an instance of an
object." So after selecting this
ddl.Items.Insert(0, "-- Select Company --")
i get the error
Any workarounds