This code will retrieve list items from a given list and append them to a given DropDownList.
C# Code :
SPSite ospSite = new SPSite("http://spserver");
SPWeb ospWeb = ospSite.AllWebs["testweb"];
SPList ospList = ospWeb.Lists["Test Document Library"];
int ct = ospWeb.Lists["Test Document Library"].Items.Count;
for (int idx = 0; idx < ct - 1; idx++)
{
//Following line retrieves Name value from the list item.
DropDownList1.Items.Add(ospList.Items[idx].GetFormattedValue("Name").ToString());
}
Monday, December 28, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment