Monday, June 30, 2014

Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource.

Does this work?



protected override void CreateChildControls()
{
SPSite site = SPContext.Current.Site;
SPWeb web = SPContext.Current.Web;
SPQuery query = new SPQuery();
SPList list1 = web.Lists.TryGetList("Vendor");
if list1 != null)
{
DataTable dtvendor = new DataTable();
dtvendor = list1.GetItems(query).GetDataTable();
drpList.DataSource = dtvendor;
drpList.DataTextField = "Company";
drpList.DataValueField = "ID";
drpList.DataBind();
Controls.Add(drpList);
drpList.SelectedIndexChanged += new EventHandler(this.ddlAllLists_SelectedIndexChanged);
}
}



Good Luck!


Alex


No comments:

Post a Comment