I have a asp.net application in that I am using ado.net entity framework in which I want to bind the two column in that dropdown.for example:
in database their two column of First_name ,Last_name .I want these two columns value come in a single dropdown using C#.
How to do that?
public void BindClients()
{
//To Bind the Client Names for Searching Option
var ddlclientnames = (from ddl in mortgageentity.Clients select ddl).ToList();
if (ddlclientnames.Count() > 0)
{
ddlsearchclient.DataSource = ddlclientnames;
ddlsearchclient.DataValueField = "Client_ID";
ddlsearchclient.DataTextField = "LastName";
ddlsearchclient.DataBind();
}
}
Unless you use the Fullname a lot, I would suggest to use an anonymous type in your select.
This also limits the amount of data that will be done in your select and other overhead.