Click here to Skip to main content
15,906,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to populate values in dropdownlist with a sharepoint custom list
Posted

1 solution

SPWeb web = SPContext.Current.Web;
SPList list = web.GetListFromUrl("ListUrl");
SPQuery query = new SPQuery();
VB
//I suppose field1 is the column which contains data in SPList
            //needs to be displayed in dropdownlist
            query.ViewFields = "<FieldRef Name='Field1' />"

;
SPListItemCollection spItemColl = list.GetItems(query);
foreach (SPListItem oItem in spItemColl)
{
ddlOutput.Items.Add(Convert.ToString(oItem["Field1"]));
}
 
Share this answer
 

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