如何在vb的下拉列表中删除选定的值? [英] How to remove selected value in drop down list in vb ?

查看:361
本文介绍了如何在vb的下拉列表中删除选定的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai

在我的网络应用程序中,我将在下拉列表中绑定数据,并从列表中选择一个值作为选定值,如果我从下拉列表中单击向下箭头,则选中的值将显示在下拉框中,选中的值也会出现在列表中(即)2下方出现在下拉框中,另一个出现在列表中,我需要的是如何从列表中删除该值,bcz选中的值显示在顶部。



是否有可能,如果不可能也请回复。就像不能做....

请回复asap



问候

AravindB



编辑

----------- ------

谢谢你的回复。我将使用下拉列表,我将在下拉列表中绑定数据,我从下拉列表中选择一个值,在选择最高selecet值后出现在列表中也出现值,我的需要是在选择值之后,只显示在顶部并在同一下拉列表框中删除表单列表

解决方案

使用这个
项目的属性默认选择为
,另一个属性为AppendDataBoundItems = true







 

>< asp:DropDownList ID =DropDownList1runat =serverAppendDataBoundItems =true>

< asp:ListItem Text =VolvoValue =1Selected =True>< / asp:ListItem>

< asp:ListItem Text = MarutiValue =2>< / asp:ListItem>

< asp:ListItem Text =SwiftValue =3>< / asp:ListItem>

< / asp:DropDownList>


如果我理解正确,这就是你想要的:

下拉值为1, 2,3,4,5

你选择4.

现在再次单击下拉列表的向下箭头,它显示4作为选定值。

现在发生的事情:显示值1 ,2,3, 4,5列表

你想做什么:在列表中显示值1,2,3,5。从列表中删除4,只因为它已被选中。



我的解决方案:

你想做的不是标准行为下拉控制。更不用说,它只会让用户感到困惑。

你不能这样做,因为如果从列表中删除它,就无法选择它。


在ASP下拉中,据我所知,它无法完成。我在html中找到了解决方法。看看这对你有帮助。当我将格式从下拉列表更改为列表并列表下拉到这两个按钮单击时,可能是您可以在单击时执行此操作。对不起,由于我的时间不多,无法发布更好的示例。 

< 选择 id = T >
< 选项 value = volvo > Volvo < / option >
< 选项 value = saab > Saab < / option >
< 选项 = mercedes > Mercedes < / option >
< 选项 value = audi > 奥迪< / option >
< / select >
< input type = 按钮 < span class =code-attribute>önclick = T.multiple ='multiple'; value = b1 / >
< 输入 type = button önclick = T.multiple =''; value = b2 / >


写下你的下拉填充代码是回发条件因为我在下面的例子中调用了fillDropdown函数。



 如果  IsPostBack 然后 
FillDropdown()
结束 如果


Hai
In my web application,i will bind data in dropdownlist and make one values as selected value from list,selected value appear in drop down box,if i click down arrow from drop down, selected value appear in list also(i.e)2 times appear in drop down one in drop box and another one in list ,my need is how to remove that value from list,bcz selected value show in top.

Is it possible,pls reply if not possible also.like cant do....
pls reply asap

Regards
AravindB

EDIT
-----------------
thank u for ur reply.i will use drop down list ,i will bind data in dropdown and i selecte one value from dropdownlist,after select at top selecet value appear and also in the list also value appear,my need is after selecte value ,only show on top and remove form list in same dropdown list box

解决方案

use this 
There is a property for item that will be by default selected
and another property AppendDataBoundItems=true




"><asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true" >
<asp:ListItem Text ="Volvo" Value ="1" Selected ="True" ></asp:ListItem>
<asp:ListItem Text ="Maruti" Value ="2"></asp:ListItem>
<asp:ListItem Text ="Swift" Value ="3"></asp:ListItem>
</asp:DropDownList>


If I understand correctly, this is what you want:
A drop down has values 1, 2, 3, 4, 5
First time, you click on down arrow of the drop-down, it shows all values in the list.
You select 4.
Now again you click on down arrow of the drop-down, it shows 4 as the selected value.
What happens now: shows value 1, 2, 3, 4, 5 in list
What you want to do:show values 1, 2, 3, 5 in list. Get rid of 4 from the list, just because it's selected.

My solution:
What you want to do is not the standard behaviour of drop down control. Not to mention, it will just confuse the users.
You can not do it, because if you remove it from the list, it can not be selected.

In ASP drop down, as far as I know, it can not be done. I found a work-around in html drop down. See if that helps you. As I change the format from drop-down to list and list to drop-down in these two button clicks, may be you can do that on click. Sorry, can not post better example as I'm running out of time.

<select id="T">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>
    <input type="button"  önclick="T.multiple = 'multiple';" value="b1" />
    <input type="button"  önclick="T.multiple = '';" value="b2" />


write your dropdown fill code in is post back condition As i call fillDropdown function in example below .

If Not IsPostBack Then
   FillDropdown()
       End If


这篇关于如何在vb的下拉列表中删除选定的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆