【发布时间】:2012-08-28 00:21:49
【问题描述】:
我尝试了一些在 Google 和 Stack Overflow 上找到的建议,但它们都不起作用。
这是我的数据绑定到的下拉列表控件 - 请注意,它没有 DataSouce 或 DataSourceID 的值
<asp:DropDownList ID="CuisineList" runat="server" Width="100"
onselectedindexchanged="CuisineList_SelectedIndexChanged">
</asp:DropDownList>
下面是将数据绑定到下拉列表控件的代码:
BLgetMasterData obj = new BLgetMasterData();
var cusineList = obj.getCuisines();
CuisineList.DataSourceID = null;
CuisineList.DataSource = cusineList;
CuisineList.DataBind();
CuisineList.Items.Insert(0, "Any");
CuisineList.SelectedValue = "Any";
【问题讨论】:
-
不要认为这会导致您的问题,但为什么会有这条线?
CuisineList.DataSourceID = null; -
这是我在堆栈溢出中找到的建议之一
-
我建议你三遍检查没有其他代码设置
DataSourceID,错误很清楚,不会出错 -
我在我的项目中执行了“查找”,但没有引用 datasourceid
标签: c# asp.net linq-to-entities datasource