结果要如下:
<select style="WIDTH: 96pt" size="1" name="apply_func">
<option value="" selected>=请选择岗位类别=</option>
<option style="color: blue" value="===经营/管理/策划类===">===经营/管理/策划类===</option>
    <option value="总裁/总经理/CEO">总裁/总经理/CEO</option>
    <option value="经理助理">经理助理</option>
    <option value="厂长/副厂长">厂长/副厂长</option>              
<option style="color: blue" value="===市场销售/营销类===">===市场销售/营销类===</option>                 
    <option value="市场总监/经理/营销管理">市场总监/经理/营销管理</option>              
    <option value="市场/行销策划">市场/行销策划</option>
    <option value="销售经理/主管">销售经理/主管</option>
             
                
<option style="color: blue" value="===照明设计/工程师类===">===照明设计/工程师类===</option>
                
   <option value="工程技术员">工程技术员</option>
   <option value="电子工程师">电子工程师</option>              
</select>注,有"===="的为第一分类
    没有的为第一分类下面的次分类
现我要用服务控件
<asp:DropDownList ID="DropDownList1" runat="server">
        </asp:DropDownList>
来什么样去绑定成上面那个样子呢下面是我的数据表
string strComm = "SELECT * FROM data_employment_Class WHERE rank=1";第一分类表strComm = "SELECT * FROM data_employment_Class Where rank=2 and Parent_ID=" + rs["Class_id"] + "";第二分类表
rank为第几分类
Parent_ID关联第一分类的Class_id

解决方案 »

  1.   

    你的数据库里有====的么?
    就当你有了。
    返回IDataReader rs
    while(rs.read())
    {
      ListItem item = new ListItem();
      list.Text = rs["name"].ToString();
      list.Value = rs["id"].ToString();
      DropDownList1.Items.Add(item);
    }返回DateSet ds
    DropDownList1.DataSource = ds;
    DropDownList1.DataTextField = "name";
    DropDownList1.DataValueFiels = "id";
    DropDownList1.DataBind();
      

  2.   

    还有一个就是,当别个人注册选取后,但又要修改资料时,那什么根据所读出的值去选上对应的项呢
    **************************************************************
    foreach(ListItem item in DropDownList1.Items)
    {
      item.Selected = false;
      if(item.Value = "要选定的值";
         item.Selected = true;
    }
      

  3.   

    我没用服务控件可以做出来。但修改时根据所读出的值去选上对应的项不行==========前台代码
     <select style="WIDTH: 96pt" size="1" name="apply_func">
        <option value="">=请选择岗位类别=</option>
      </select><asp:repeater id="ParentRepeater" runat="server">
        <itemtemplate>
        <option style="color: blue" value="===<%# DataBinder.Eval(Container.DataItem,"ClassName") %>===">===<%# DataBinder.Eval(Container.DataItem,"ClassName") %>===</option>
            <asp:repeater id="child" datasource='<%# DataBinder.Eval(Container, "DataItem.myrelation1") %>' runat="server">
               <itemtemplate>
            <option value="<%#DataBinder.Eval(Container.DataItem,"ClassName")%>"><%#DataBinder.Eval(Container.DataItem,"ClassName")%></option>
             </itemtemplate>
            </asp:repeater>
        </itemtemplate>
       </asp:repeater>
    </select>
    后台代码========== private void Class_Load()//分类
    {
            string strComm = "SELECT * FROM data_employment_Class WHERE rank=1"; 
    DataSet myDataSet = new DataSet();
            SqlDataAdapter myDataAdapter = new SqlDataAdapter(strComm, Function.strDcndb()); 
    myDataAdapter.Fill(myDataSet,"1");
            strComm = "SELECT * FROM data_employment_Class Where rank=2";
            myDataAdapter = new SqlDataAdapter(strComm, Function.strDcndb()); 
    myDataAdapter.Fill(myDataSet,"2");        DataColumn Parent = myDataSet.Tables["1"].Columns["Class_ID"];
            DataColumn Child = myDataSet.Tables["2"].Columns["Parent_ID"]; 
    myDataSet.Relations.Add("myrelation1",Parent,Child);
    ParentRepeater.DataSource=myDataSet.Tables["1"].DefaultView; 
    ParentRepeater.DataBind();
    }
    '-----------就是这样,我这样是没有绑定下拉框的,所以修改时不行,谁帮帮我,分不是问题,谢谢
      

  4.   

    就是说编辑的时候要求选上对应的值是吧?
    在ItemBound事件里写就好了.
      

  5.   

    看懂了,lz为什么要搞得那么复杂呢,讲讲你的需求,你就一个dropdownlist吗?
      

  6.   

    是的,就一个dropdownlist,可以做到吗/?
      

  7.   

    这样吧,先建立一个实体,例如BigSort,然后定义属性。
    public class BigSort
    {
    private string sortname;
    public string SortName
    {
      get{return sortname;}
      set{sortname = value;}
    }private string sortid;
    public string SortID
    {
      get{return sortid;}
      set{sortid= value;}
    }
    }先返回大类的DataReader rs
    ArrayList aBig = new ArrayList();
    while(rs.Read())
    {
       BigSort big = new BigSort();
       big.SortName = rs["name"].ToString();
       big.SortID = rs["id"].ToString();
       aBig.Add(big);
    }写一个函数根据第一类ID返回第二类的DataReader rs2,例如是getSmallSort(string id)foreach(BigSort big in aBig )
    {
    ListItem item = new ListItem();
    item.Value = big.SortID;
    item.Text = "====" + big.SortName + "====";
    DropDownList.Items.Add(item);
    IDataReader rs2 = getSmallSort(bid.SortID);
       while(rs2.Read())
        {
         ListItem item = new ListItem();
         item.Value = rs2["id"].ToString();
         item.Text = rs2["name"].ToString();
         DropDownList.Items.Add(item);
         }
        rs2.close();
    }
    希望你能看得懂
      

  8.   

    其实lz可以考虑改一下数据库结构,用一个表就行了,利用线性编码,例如大类用101,102,103...表示,第二类用101101,101102,101103...表示
    搜索的时候只要select * from xxx where id like '101%'就可以搜出大类101下的所有小类了,如此类推。
      

  9.   

    其实最好是把所有类别都放在实体类里按顺序布局好,最后在拿出来循环加到dropdownlist里,这样比较科学