Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello ,

i binding the dropdownlist using WCF asp.net using entity framework linq
but i am getting error connection closed.

My code:
public void FillClientNameDropDown(long clientid, DropDownList ddl)
{
using (ListClientServiceReference.ClientListClient client = new ListClientServiceReference.ClientListClient())
{

ddl.DataSource = client.GetName(clientid);
ddl.DataValueField = "ClientId";
ddl.DataTextField = "Name";

ddl.DataBind();

ddl.Items.Insert(0, new ListItem("-Select Product Type-", "-1"));
}

}

plz tell me how to slove.
i search on the google but i am not getting any answer.
Posted

1 solution

To use a dropdown list in your view you need to populate a SelectList object. Example:

C#
//In my controller I create a list of all items in db.Tags, with value is Id, text is Name and selected value is tagstologos.TagId.
ViewBag.TagId = new SelectList(db.Tags, "Id", "Name", tagstologos.TagId);

//In my view I create the dropdownlist with a HTML helper. 
@Html.DropDownList("TagId", String.Empty)
 
Share this answer
 
Comments
sadhana4 1-Jun-13 4:18am    
how to use the selectList for dropDownlist using wcf

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900