简体   繁体   English

VB.NET中Dropdown的选定值

[英]Selected Value of Dropdown in VB.NET

I have the following dropdown in my page: 我的页面中有以下下拉列表:

<asp:DropDownList ID="cboEmployerType" runat="server" TabIndex="8" Width="60%" onclick="javascript:shouldsubmit=false;">
                       <asp:ListItem Value="Null">-Select-</asp:ListItem>
                       <asp:ListItem Value="E">Employer</asp:ListItem>
                       <asp:ListItem Value="O">OJT Provider</asp:ListItem>
                   </asp:DropDownList>

When I click a certain button, my dropdown should have selected value as -Select- . 当我单击某个按钮时,我的下拉列表应该选择值为-Select- How do I do this? 我该怎么做呢?

I tried this in my code behind but doesn't work. 我在我的代码中尝试了这个,但是没有用。

cboEmployerType.SelectedValue = "null"

You can set 你可以设置

cboEmployerType.SelectedIndex = 0

This will select your first value. 这将选择您的第一个值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM