Home > SharePoint 2010 > Bind DropdownList from SharePoint List

Bind DropdownList from SharePoint List

Hi all,

try this example to Bind DropdownList from SharePoint List

if (!Page.IsPostBack)
DataSet ds = new DataSet();
SPSite mySite = SPContext.Current.Site;
SPWeb myWeb = mySite.OpenWeb();
SPList list = myWeb.Lists["ListName"];
DataTable DTable_List = list.Items.GetDataTable();
DTable_List.TableName = "MyDTable";
DropDownList.DataSource = ds.Tables["MyDTable"];
DropDownList.DataTextField = "FieldName";
DropDownList.DataValueField = "FieldName";
DropDownList.SelectedIndex = 0;

Hope this helps

Good Luck

Categories: SharePoint 2010
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: