c# - 静态下拉列表填充不正确的值

标签 c# html

我有一个带有以下 html 的静态下拉菜单。

    <asp:DropDownList width="100px" ID="dropDownActive"  Runat="server">
         <asp:ListItem Text="Inactive" Value="0"/>
         <asp:ListItem Text="Active" Value="1" />
    </asp:DropDownList>

我尝试根据数据填充所选值,但在我到达之前它的值为 0,并且不会接受新值。

dropDownActive.SelectedValue = (support.Active)? "Active": "Inactive";

最佳答案

下拉列表的值是“0”和“1”,而不是“有效”和“无效”

dropDownActive.SelectedValue = (support.Active)? "1": "0";

关于c# - 静态下拉列表填充不正确的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6541559/

相关文章:

html - Logo 上传在括号中工作但不能通过 Cyber​​Duck 进行

html - innerHTML/textContent setter 中令人困惑的性能差异

html - 居中包装内的两个 div ..很困惑

javascript - 使用javascript在新选项卡中打开图像和文本

javascript - 双击jQuery克隆div并单击更改样式

c# - 替换 Visual Studio 中的所有属性

c# - 如何在 Visual Studio 中开发独特的 GUI?

c# - TryParse 无法正确解析

c# - 设计视角 : Static Methods vs. 类

c# - 使用 MVVM 在代码中动态设置资源