ASP.NET: Why does ListControl.Text return the *value* of the selected ListItem rather than the *text*?

耗尽温柔 提交于 2019-12-04 19:54:30

I checked that out before using .NET Reflector. If ListItem.Text is null, it returns ListItem.Value instead; if that is null, it returns an empty string. It works in vice versa for ListItem.Value too. So it's not the ListControl doing this, it's selected item itself.

HTH.

If the code used to process an ASPX page defines all controls using the ITextControl interface, the Text property is the only property available. When processing a ListControl, most of the business logic I write cares about the value of the selected item, not the text. Thus, in my opinion, the current behavior is the desired behavior, even if it is not necessarily the expected behavior.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!