I have a Template via:
public class OwnedProvinces
{ public Guid ProvinceID;
public string ProvinceName;
}
And I created a list with this template here:
List<OwnedProvinces> getinfo = (from upi in db.Utopia_Province_Data_Captured_Gens
where upi.Owner_User_ID == SQLStatementsCS.UserID()
where upi.Province_Name != string.Empty
select new OwnedProvinces { ProvinceName = upi.Province_Name, ProvinceID = upi.Province_ID}).ToList();
The problem with this when I try to bind it to the Dropdown list like so:
ddlSelectProvince.DataTextField = "ProvinceName";
ddlSelectProvince.DataValueField = "ProvinceID";
ddlSelectProvince.DataSource = getinfo;
ddlSelectProvince.DataBind();
It throws the Error:
DataBinding: 'OwnedProvinces' does not contain a property with the name 'ProvinceName'.
Basically, it can't find the property ProvinceName in the List, but makes no sense to me. If I do an anonymous query, it works, but when I assign it to the class OwnedPRovinces, it throws this error...