0

I'm using programmatically creating dropdowns and got one unexpected problem: i cant get the value of the the selected item in dropdownlist. WebService works perfectly and all dropdowns are updating good. The source code is:

DropDownList ddl = (DropDownList)up.FindControl("tab_").FindControl("ddlroom_");
string val = ddl.SelectedItem.Value; - on this command i have got an error 

Object reference is not set to an istance of an object

What should i do? Is it any samples how to get selected value from CascadingDropDown?

Rahul Singh
  • 21,585
  • 6
  • 41
  • 56
john
  • 31
  • 4
  • possible duplicate of [What is a NullReferenceException and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Rahul Singh Mar 12 '15 at 09:31
  • Have you checked what is the value of ddl? – SelvaS Mar 12 '15 at 14:34
  • What are you setting the value to from your data source? That is specifically saying that the value field of your dropdown is null. you can either check for null and do some error catching or make sure it has a value to begin with. If you need more help, please post more code, specifically where you are binding your dropdown and what you are setting the text and value fields. – MaCron Mar 12 '15 at 14:00

0 Answers0