Link to home
Start Free TrialLog in
Avatar of enrique_aeo
enrique_aeo

asked on

dropdownlist : Object reference not set to an instance of an object.

I have a page where this dropdownlist is hidden ddlDepartamento
 but elsewhere in the code asks for this combo as follows
If ddlDepartamento.SelectedItem.Value.Equals("%") Then
 therefore I have this error:
 Object reference not set to an instance of an object.
 as I can ask for a dropdownlist that is not visible in the html
Avatar of kaufmed
kaufmed
Flag of United States of America image

What function/method are you calling If ddlDepartamento.SelectedItem.Value.Equals("%") Then in?
Hi,
when you make control Visible="false" then it is not rendered in output, you can use css style hidden as
style="display:none"
Hope it will help
Thanks
Avatar of enrique_aeo
enrique_aeo

ASKER

kaufmed: is a code that is already done
IJZ: everything I do in the code behind

then make sure that
ddlDepartamento.SelectedItem!=null
or ddlDepartamento.SelectedIndex>0
ASKER CERTIFIED SOLUTION
Avatar of Imran Javed Zia
Imran Javed Zia
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>  kaufmed: is a code that is already done

I mean are you calling it in Form_Load, OnFormLoad, OnLoadComplete, etc.