html控件想要挂接数据库:<select id="select2" name="select2">在.cs中想要用数据库里的数据附给 select2 怎么办? 我不想用web控件. 谢谢非常近急!希望能给个详细代码!在线等!

解决方案 »

  1.   

    make it a server control<select id="select2"  runat="server" >protected HtmlSelect select2;..//you can do databinding on select2otherwise, you need to do something like (ugly)<select id="select2" name="select2">
    <asp:Repeater ..>
     <ItemTemplate>
      <option value='<%# .. %>'><%# ..%></option>
      </ItemTemplate>
    </select>
      

  2.   

    为什么 不能用?
    select2.DataSource=das.Tables["person"].DefaultView;
    select2.DataBind();
      

  3.   

    you need to set DataTextField and/or DataValueField property
      

  4.   

    runat="server"
    同意楼上的。
      

  5.   

    那就像以前的ASP方式  循环再读出