function abc(){
string Code =
(combobox.SelectedItem.Value != null) ? combobox.SelectedItem.Value.ToString()
: string.Empty;
(save function
....)
}
Anyone knows how to I can proceed with save function if the combobox is null value and it pop up error system null reference exception?
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