Here is my code -
combo.DisplayMember = "Caption";
combo.ValueMember = "PortName";
combo.Items.Add(new { PortName = "port", Caption = "caption" });
//Null reference exception here-
String PortName = combo.SelectedValue.ToString();
What did I miss?
UPDATE-
//the following line has solved my problem- dynamic item = cmbPortNo.SelectedItem; string PortName = item.PortName;
Maybe you just missing
combo.SelectedIndex = 0;line