单击DropDown List后,第一个选项将不可见... [英] First option will be invisible After click on DropDown List...

查看:75
本文介绍了单击DropDown List后,第一个选项将不可见...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我的要求是,在页面加载时用户可以看到---选择颜色 - 选项。点击下拉列表后,用户只能看到红色绿色和蓝色选项。所以如何隐藏---选择颜色 - 选项。但我的下面的代码仍然显示 - 选择颜色---,红色,蓝色& 绿色.plz帮帮我。



谢谢&问候

Papu

.aspx



hi all,

My Requirement is, at page load an user can see "---Select color--" option.after click on dropdown list,user can see only "Red" "Green" and "Blue" options.so how to invisible the "---Select color--"option. but my below code still displaying "--select color---","red","blue" & "Green" .plz help me.

Thanks & regards
Papu
.aspx

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"

    onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>---Select color--</asp:ListItem>
<asp:ListItem>Red</asp:ListItem>
<asp:ListItem>Green</asp:ListItem>
<asp:ListItem>Blue</asp:ListItem>
</asp:DropDownList>





.aspx.cs





.aspx.cs

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    if (DropDownList1.SelectedIndex != 0)
    {
       DropDownList1.Items.Remove("---Select color--");
    }
}

推荐答案

它在这里不起作用。



以下是询问者的预期:

1. 先尝试你想做什么!你可能会发现它并不那么难。

2.制定你所做的事情看似问题/不工作。



尝试一下,告诉你是否面临问题。

各位会员非常乐意帮忙。






现在,您必须这样做:

1.在交换时提升事件

2.如果您发现所选项目不是值= 0,隐藏/删除第一项



您可以根据需要在客户端或服务器端执行此操作。
It does not work like this here.

Here is what is expected of enquirers:
1. TRY first what you want to do! You may find that it''s not that hard.
2. Formulate what was done by you that looks like an issue/not working.

Try them and tell if you face issues.
Members will be more than happy to help like this.



For now, you have to do:
1. Raise an event onchange
2. If you find the selected item other than value=0, hide/remove the first item

You can do it on client side or server side as per you need.


这篇关于单击DropDown List后,第一个选项将不可见...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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