• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 521
  • Last Modified:

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
0
enrique_aeo
Asked:
enrique_aeo
  • 3
  • 2
1 Solution
 
käµfm³d 👽Commented:
What function/method are you calling If ddlDepartamento.SelectedItem.Value.Equals("%") Then in?
0
 
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
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
0
 
enrique_aeoAuthor Commented:
kaufmed: is a code that is already done
IJZ: everything I do in the code behind

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
then make sure that
ddlDepartamento.SelectedItem!=null
or ddlDepartamento.SelectedIndex>0
0
 
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
I think you are using vb.net then use
ddlDepartamento.SelectedItem<>Nothing
or
ddlDepartamento.SelectedIndex>0
0
 
käµfm³d 👽Commented:
>>  kaufmed: is a code that is already done

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

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now