List<Customer> _customer = new CustomerBLL().GetAllCustomers();
if (_customer != null)
{
ddlCustomer.DataSource = _customer;
ddlCustomer.DataValueField = "CustomerId";
ddlCustomer.DataTextField = "CustomerName";
ddlCustomer.DataBind();
ddlCustomer.Items.Insert(0, new ListItem("Select Customer", "0"));
}
Try to use this code.
Here GetAllCustomers(); is the method which returns List of customer and the method is in CustomerBLL() class. The method returns CustomerId, CustomerName & so on as a List. In the drop-down list i'm binding CustomerId as "DataValueField" & CustomerName as "DataTextField". And the last of all i'm adding "Select Customer" at the top of the drop-down list, thought you may need it so i add it too.
Hope it would help you.
Thanks