简体   繁体   English

从VB.Net中的复选框显示下拉列表值

[英]Display Dropdown values from checkbox in VB.Net

I need your help with the following situation: I have a dropdownlist as follows: 在以下情况下,我需要您的帮助:我的下拉列表如下:

<asp:dropdownlist id="myvalues" runat="server">
<listitem value="Low">Low</listitem>
<listitem value="Medium">Medium</listitem>
<listitem value="High">High</listitem>
<listitem value="Super High">Super High</listitem>
</dropdownlist>

I need to call the above dropdown values from a checkbox as follows: 我需要从复选框中调用上述下拉值,如下所示:

<asp:CheckBox ID="mybox" runat="server" Text="Click Me" Checked="true"/>

When I save the values, it works fine, but when I call the edit it display the first value only. 当我保存值时,它工作正常,但是当我调用编辑时,它仅显示第一个值。 I would like to bring the value saved, I also need to code in VB.Net I have tried the following but didn't work: 我想带来保存的价值,我还需要在VB.Net中进行编码,我尝试了以下操作但没有成功:

If mybox.checked = True Then
'myvalues.SelectedValue = true
 myvalues.Items(myvalues.Items.Count -1).Selected = True
else
'to do somethig here'
End If

The problem is that when I try to edit, it brigs only the first dropdown value, which is Low not the saved one. 问题是,当我尝试编辑时,它只会桥接第一个下拉值,即“ 低”而不是已保存的值。 Can Anyone help me with matter? 有人可以帮助我吗? I'd like to thank in advance for your great support. 在此先感谢您的大力支持。

In your If statement you are doing this: 在您的If语句中,您正在执行以下操作:

myvalues.SelectedValue = true

I think you meant: 我想你的意思是:

myvalues.SelectedValue = "Super High"    'or whatever dropdown value you saved

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

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