public void SendRoomIDtoCheckINNew(int RID)
{
try
{
object[,] ParamArray = new object[,] { { "@RoomID", RID } };
DataSet ds = new DataSet();
ds = DB.ExecuteQuery_SP("SelectRoomDetailsForGridByID", ParamArray);
if (ds.Tables.Count > 0)
{
cmbroomcat.DataSource = ds.Tables[0];
cmbroomcat.Text = ds.Tables[0].Rows[0]["RoomCategoryName"].ToString();
cmbroomno.DataSource = ds.Tables[0];
cmbroomno.DisplayMember = ds.Tables[0].Rows[0]["RoomNo"].ToString();
cmbroomno.Text = ds.Tables[0].Rows[0]["RoomNo"].ToString();
//cmbroomno.ValueMember = ds.Tables[0].Rows[0]["RoomID"].ToString();
txtCapacity.Text= ds.Tables[0].Rows[0]["RoomCapacity"].ToString();
}
}
catch (Exception ex) { ex.ToString(); }
}
above is my code but when i try to bind dt object to respective combo box and textbox it is not binding what is the reason behing it i am still confussing


Arunava BhattacharjeeRank #635 · 3.8K reputationPosted Sep 30, 2014, 2:41 AM EDT
public DataTableCollection Tables { get; }
Arunava BhattacharjeeRank #635 · 3.8K reputationPosted Sep 30, 2014, 1:24 AM EDT
Check this post in c-sharp corner :
http://www.c-sharpcorner.com/UploadFile/0f68f2/programmatically-binding-datasource-to-combobox-in-multiple/
Your problem is table returns a DataSetCollection where DataSource expects an Enumerable. So its a type mismatch.
Also try to bind the parameter to CommandParameter, search in Google about SQL Injection. If this post helps you then please mark the answer as accepted.
Munesh SharmaRank #174 · 13.9K reputationPosted Sep 30, 2014, 1:43 AM EDT
mohammed shamsheerRank #4,152 · 361 reputationPosted Sep 30, 2014, 1:50 AM EDT
mohammed shamsheerRank #4,152 · 361 reputationPosted Sep 30, 2014, 4:21 AM EDT
cmbroomcat1.SelectedIndex = -1;