DropDownList的用法

<asp:DropDownList runat="server" ID="ddlStatus">
<asp:ListItem Text="全部" Value="-1" />
<asp:ListItem Text="正常" Value="1" />
<asp:ListItem Text="禁用" Value="0" />
</asp:DropDownList>

若要是想在.cs中设置DropDownList的选项值:ddlStatus.SelectedValue=“1”;那么在控件中显示的就是“正常”选项;

DropDownList绑定时候的重要属性:

            this.ddlUserRole.DataTextField = "RoleName";  //显示在下拉框中的内容
this.ddlUserRole.DataValueField = "Id"; //这个表中唯一的东西,一般是主键

待补充。。。
编辑器加载中...

原文地址:https://www.cnblogs.com/heluo/p/2425770.html