默认选择的文本为“选择”在下拉组合框中 [英] Default Selected text as a "Select" in drop down combo box

查看:52
本文介绍了默认选择的文本为“选择”在下拉组合框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想将我的组合框默认选中值设为选择文字,有没有属性?

Plzz帮助。

Thanx提前

解决方案

ListItem newItem = new ListItem();

newItem.Text =Select;

newItem.Value =0;

DropDownName.Items.Add(newItem);


你必须将第一个选项设置为正在选择例如:

 <   select     id   =  myDropDown >  
< 选项 > 选择水果.... < / option >
< 选项 > Apple < / option >
< 选项 > Banana < / option >
< 选项 > Pear < / option >
< / select >


在页面加载中尝试此操作,但仅限于 Ispostback false



 dropdown1.Items.Insert( 0  new  ListItem(   - 选择 -   0)); 


Hi
I want to set my combo box default selected value as "Select" text ,is there are any property ??
Plzz help.
Thanx in advance

解决方案

ListItem newItem = new ListItem();
newItem.Text = "Select";
newItem.Value = "0";
DropDownName.Items.Add(newItem);


You have to set the 1st option as being "Select" eg:

<select id="myDropDown">
<option>Select a fruit....</option>
<option>Apple</option>
<option>Banana</option>
<option>Pear</option>
</select>


Try this in your page load but only when Ispostback is false:

dropdown1.Items.Insert(0, new ListItem("--Select--", "0"));


这篇关于默认选择的文本为“选择”在下拉组合框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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