首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎么给 FormView控件中得DropDownList绑定数据源

2011-12-10 
如何给 FormView控件中得DropDownList绑定数据源?如何给 FormView控件中得DropDownList绑定数据源?用代码

如何给 FormView控件中得DropDownList绑定数据源?
如何给 FormView控件中得DropDownList绑定数据源?
用代码绑定也报错!
DataBinding:“OfficeChannel.DAL.UserList”不包含名为“MapDisplayText”的属性。

我的代码!
用控件访问DAL层得方法出错
  public IQueryable JobID1()
  {
  DALDataContext ocDC = new DALDataContext(ConfigurationManager.ConnectionStrings["OfficeChannelConnectionString_Web"].ConnectionString);

  var UserInfo = from UL in ocDC.CommonMapList
  where UL.TypeFlag == 1
  select UL.MapDisplayText;
  return UserInfo;

或者pageload中直接绑定也出错
DropDownList IndustryID = (DropDownList)FormView1.FindControl("IndustryID");
  IndustryID.DataSource = from cml in ocDC.CommonMapList
  where 1 == cml.TypeFlag
  select cml;


前台代码
<asp:DropDownList ID="IndustryID" runat="server" 
   
  SelectedValue='<%# Bind("MapDisplayText") %>' Width="66px" 
  >
  </asp:DropDownList>


[解决办法]
SelectedValue=' <%# Bind("MapDisplayText") %>' Width="66px" 
把这个删除了,就因为他,给他绑定最好用代码绑

热点排行