Cannot bind data table elements to combobox

5 pts.
Tags:
ComboBox
WinForms
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 behind it? I'm still confused.
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Refer to this article, having good example. Hope this will help you.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • ToddN2000
    Looks like your databind command is missing.

    It should look like this

    cmbroomno.DataSource = ds.Tables[0];
    cmbroomno.DataBind();





    128,275 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: