Get The list items from the sharepoint list, Here am getting data from the Splessons List , and then data was binding into the the Dropdown.
[csharp]private void GetListItems()
{
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite oSite = new SPSite(SPContext.Current.Web.Url))
{
using (SPWeb objWeb = oSite.OpenWeb())
{
SPList oList = objWeb.Lists["Splessons"];
SPListItemCollection oListCollection = oList.GetItems();
ddlLocation.DataSource = oListCollection.GetDataTable();
ddlLocation.DataValueField = "ID";
ddlLocation.DataTextField = "Location";
ddlLocation.DataBind();
}
}
});
}
catch (Exception ex)
{
Page.ClientScript.RegisterClientScriptBlock(typeof(SPAlert), "alert", "<script language="\"javascript\""></script>");
}
}
[/csharp]