我是靠谱客的博主 苹果舞蹈,这篇文章主要介绍dropdownlist控件 添加“选项”,现在分享给大家,希望可以做个参考。

dropdownlist控件 “选项”添加示例

 

dropdownlist控件 “选项”添加示例

1、添加项第一种方法
                ListItem item4 = new ListItem("插入选项1", "1");//"1"为插入位置的索引
                this.DropDownList1.Items.Insert(2, item4);//插入到指定位置

2、添加项第二种方法:
                ListItem ltCu = new ListItem();
                ltCu.Value = "3";//关联的值
                ltCu.Text = "插入项2";//显示的文字
                this.DropDownList1.Items.Add(ltCu);//添加到DropDownList1

3、添加项第三种方法
                this.DropDownList1.Items.Insert(0, new ListItem("-请选择-", "-1")); //"0"为插入位置的索;"-请选择-"为显示时的文字;"-1"为关联的值

最后

以上就是苹果舞蹈最近收集整理的关于dropdownlist控件 添加“选项”的全部内容,更多相关dropdownlist控件 内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(96)

评论列表共有 0 条评论

立即
投稿
返回
顶部