---
title: "system nullreferenceexception dropdownlist"  
description: "system nullreferenceexception dropdownlist"  
author: "Anonymous User"  
published: 2014-01-22  
updated: 2014-01-23  
canonical: https://www.mindstick.com/forum/1860/system-nullreferenceexception-dropdownlist  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# system nullreferenceexception dropdownlist

```
function abc(){     string Code =
(combobox.SelectedItem.Value != null) ? combobox.SelectedItem.Value.ToString()
: string.Empty;     (save function
....)}
```

[Anyone](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) knows how to I can proceed with save [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) if the [combobox](https://www.mindstick.com/articles/57/display-record-according-to-combobox-selection-in-csharp-dot-net) is [null value](https://www.mindstick.com/forum/23045/document-body-appendchild-has-a-null-value) and it [pop up](https://answers.mindstick.com/qa/50233/what-to-do-with-the-issues-that-may-pop-up-at-the-time-of-usb-device-installation) [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing) [system](https://www.mindstick.com/articles/23411/the-most-effective-method-to-find-the-perfect-small-business-phone-system-for-your-business) null [reference exception](https://www.mindstick.com/forum/158621/what-is-a-null-reference-exception-and-how-can-it-occur-in-an-asp-dot-net-mvc-project)?

## Replies

### Reply by Pravesh Singh

Hi Jeet,

You didn't post where you get the NullReferenceException, however it's most likely when you are performing this evaluation

combobox.SelectedItem.Value != null

The ComboBox's SelectedItem property will return null if nothing is selected. If you call the Value property on the null selected item, you'll get a NullReferenceException. What you should be checking is:

combobox.SelectedItem != null


---

Original Source: https://www.mindstick.com/forum/1860/system-nullreferenceexception-dropdownlist

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
