how to add items to dropdownlist

Posted by Oswaldlily under ASP.NET on 12/21/2011 | Points: 10 | Views : 6575 | Status : [Member] | Replies : 1
How to add into dropdownlist through mapper

<asp:DropDownList ID="ddl" runat="server"></asp:DropDownList>

ddlmapper ddm;
page_load
{
ddm=new ddlmapper();
loaddropdown();
}
private void loaddropdown()
{
ddl.datasource=ddm.mapperfunction("abc");
}

//mapperfunction is a function in linqmapper where i called storedprocedure which contains
single column information
//I need ddm.mapperfunction("abc") to be added into dropdownlist,ddl.
How to add it??




Responses

Posted by: Sksingh on: 12/21/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

If ddm.mapperfunction("abc") returns single column information then first of all you have to add it to any collection and then that collection has to set as datasource.

For ex:

List<datatype> lst = new List<datatype>();
lst.Add(ddm.mapperfunction("abc"));
ddl.datasource = lst;


Hope it will solve your problem.



Regards,
Sunil

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response