将项目添加到下拉列表 [英] Adding items to DropDown list

查看:88
本文介绍了将项目添加到下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从.aspx.cs页添加项目时,我可以通过以下三种方式进行操作

When I add an item from .aspx.cs page, I got three ways to do it as following

ddlCalanderName.Items.Insert(0, new ListItem("Item1" , "0"));
ddlCalanderName.Items.Insert(0, new ListItem("Item1"));
ddlCalanderName.Items.Insert(0, "Item1");



它给我相同的输出

谁能告诉我这三个之间的区别是什么?

谢谢



It gives me same output

Can any one tell me what is the diffrence betwween these three?

Thanks

推荐答案

这称为方法重载,而您正在将Insert方法的两个重载都使用.
唯一做不同的事情是第一个.它设置文本(在列表中以可视方式显示给用户)和项目的值(两个不同的东西),其他两个仅设置文本.
It''s called method overloading, and you''re using both of the overloads for the Insert method.

The only one that does something different is the first one. It sets the text (the way it appears visually to the user in the list) and the value of the item (two different things), where the other two just set the text.


这篇关于将项目添加到下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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