1,控件绑定
请选择类型:<asp:DropDownList ID="ddlCategory" runat="server" AppendDataBoundItems="True" AutoPostBack="True" DataSourceID="odsCategory" DataTextField="Name" DataValueField="Id">
<asp:ListItem Value="0" Text="请选择一项"></asp:ListItem>
</asp:DropDownList>
<asp:ObjectDataSource ID="odsCategory" runat="server" SelectMethod="GetAllCategories"TypeName="ThirdWaveBookshop.BLL.CategoryManager">
</asp:ObjectDataSource>
2,后台手动绑定
System.Data.DataView dv=conn.Exec_ex("select -1 as code,'请选择经营模式' as content from dealin union select code,content from dealin");
this.dealincode.DataSource=dv;
this.dealincode.DataTextField="content";
this.dealincode.DataValueField="code";
this.dealincode.DataBind();
this.dealincode.Items.FindByValue(dv[0]["dealincode"].ToString()).Selected=true;