Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object reference not set to an instance of an object

Status
Not open for further replies.

abds

Programmer
Dec 13, 2000
46
0
0
US
Please help,

I am getting this error in a DropDownList.SelectedIndexChanged handler.

The only line in the handler is
TextBox1.Text = DropDownList1.SelectedValue

What is this error and what do I do about it.

Thank you,

Phil

We are drowning in data, but we are starving for information.
 
Make sure that both objects exist -

In your .aspx page, make sure that objects named TextBox1 and DropDownList1 exist.

Next is to make sure that these objects are referenced in your code-behind page. The objects should be declared at the top of your class as:

protected System.Web.UI.WebControls.TextBox TextBox1
protected System.Web.UI.WebControls.DropDownList DropDownList1

The error means that you are trying to reference an object that does not exist.

Hope that helps =D

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
I don't think SelectedValue() is a valid properity of ListItems.

Try [name of drop down list].SelectedItem.Value

Jason Meckley
Database Analyst
WITF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top