selectedvalue
null
public static DataTable GetComboBoxedDataTable(DataTable oldDataTable, string valueColumn, string textColumn, string topRowValue, string topRowText, ComboBox cmb) { DataTable newDataTable = new DataTable(); newDataTable.Columns.Add(valueColumn); newDataTable.Columns.Add(textColumn); foreach (DataRow oldDR in oldDataTable.Rows) { DataRow newDR = newDataTable.NewRow(); newDR[0] = oldDR[valueColumn].ToString(); newDR[1] = oldDR[textColumn].ToString(); newDataTable.Rows.InsertAt(newDR, newDataTable.Rows.Count); } // Add your 'Select an item' option at the top DataRow dr = newDataTable.NewRow(); dr[0] = topRowValue; dr[1] = topRowText; newDataTable.Rows.InsertAt(dr, 0); cmb.ValueMember = valueColumn; cmb.DisplayMember = textColumn; return newDataTable; }
private void cmbroomno_SelectedIndexChanged(object sender, EventArgs e) { try { object[,] ParamArray = new object[,] { { "@RoomID", cmbroomno.SelectedValue } };---code where i need selected value DataSet ds = new DataSet(); ds = DB.ExecuteQuery_SP("SelectGuestDetailsForService", ParamArray);