我建了个DataGrid模版列,在其中的EditItemTemplate 中添加了一个DropDownList,我把DropDownList绑定到数据库字段,
问题,显示不了,就是说没有执行绑定。
代码如下:
<EditItemTemplate>
<asp:DropDownList id=DropDownList1 runat="server" Width="80px" DataTextField='<%# DataBinder.Eval(Container.DataItem,"city")%>'>
</asp:DropDownList>
</EditItemTemplate>

解决方案 »

  1.   

    try 1:改到<ItemTemplate>
    try 2: 请自己定一个数据绑定函数给DropDownList1
      

  2.   

    在<EditItemTemplate>里不行吗???
      

  3.   

    缺个DataValueField的吧
    <EditItemTemplate>
    <asp:DropDownList id=DropDownList1 runat="server" Width="80px" DataTextField='<%# DataBinder.Eval(Container.DataItem,"city")%>' DataValueField='<%# DataBinder.Eval(Container.DataItem,"city")%>'>
    </asp:DropDownList>
    </EditItemTemplate>