Data binding to a combobox and display the list in a drop down list

May 13 2008 11:44 PM

Dear Friends,

I want to bind data to a combo box and display it in a drop down list when it runs the application.

In the given below coding I have done coding but there are some problems. Here I have created the dataset and then load the data from data source. After that, I'm trying to bind data to the combo box and display that in the drop down list..... So, that is difficult for me..Hope anybody can help me.........

Thanks in advence.

public LostCustInfo ActiveCust()

{

SqlConnection scon = new SqlConnection(con.SetConnection());

scon.Open();

LostCustInfo LCust = new LostCustInfo();

string query = "SELECT cust_code,cust_name FROM CM_LOSTCUST WHERE active = 'Y'";

SqlCommand cmd = new SqlCommand(query, scon);

SqlDataAdapter adpt = new SqlDataAdapter(cmd);

adpt.Fill(LCust, "LostCustomer");

scon.Close();

return LCust;

}

private void ListCustomerCode()

{

LostCustInfo Lcust = new LostCustInfo();

Lcust = Lcust.ActiveCust();

if (!object.Equals(Lcust, null))

{

cboCustCode.DataSource = Lcust;

cboCustCode.DataBind(); // there is no method like this ?????

}

}


Answers (4)