大哥们:
    想把数据表中的字段 “学历”中的所有数据全部输出,有小学 中学 中专 大专 本科等,全部绑定在DropList中输出显示,相当于下拉框中显示的数据是从数据表中读出的,请问怎么做??以前只做rep 和datagird,请教给段能用的代码就行。急用的,谢谢!初学,请多多指导。
我做了一个,为什么在输出时,这样写就不行:
<asp:DropDownList id="FilmClass" runat="server"><asp:ListItem Value='<%# DataBinder.Eval(Container.DataItem,"FilmClass") %>'><%# DataBinder.Eval(Container.DataItem,"FilmClass") %></asp:ListItem>

</asp:DropDownList>

解决方案 »

  1.   

    在datasourse 中写入数据源
    dataTextField 中写入相应的学历字段
    然后绑定
      

  2.   

    后台写的吧...
    DropDownList1.DataSource = ...
    DropDownList1.DataTextField = "字段1";
    DropDownList1.DataValueField = "字段2";
    DropDownList1.DataBind();
      

  3.   

    DropDownList1.DataSource = ...
    DropDownList1.DataTextField = "值字段";
    DropDownList1.DataValueField = "主键ID";
    DropDownList1.DataBind();
      

  4.   

    <asp:ListItem Value='<%=value1%>
    <asp:ListItem Value='<%=value2%>
    不能和datagrid一样绑定
    方法
    DropDownList1.DataSource = datatable1
    DropDownList1.DataTextField = text;
    DropDownList1.DataValueField = value;
    DropDownList1.DataBind();
      

  5.   

    那前台:就是  .aspx文件中,
    <asp:DropDownList id="FilmClass" runat="server">
    的下面写什么,默认???
      

  6.   

    前台页面不用写其他的代码了,只要后台这样就可以了。
    DropDownList1.DataSource = datatable1
    DropDownList1.DataTextField = text;
    DropDownList1.DataValueField = value;
    DropDownList1.DataBind();
      

  7.   

    DropDownList1.DataSource = datatable1
    DropDownList1.DataTextField = text;
    DropDownList1.DataValueField = value;
    DropDownList1.DataBind();用后台绑定的