DropDownList获取底层对象 [英] DropDownList get underlying object

查看:126
本文介绍了DropDownList获取底层对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个DropDownList绑定到一个ObjectDataSource。当我在下拉菜单中选择一行时,如何获取底层对象(不仅仅是值或文本属性)。我试图将所选对象从DropDownList添加到Listbox的数据源,但我不知道如何引用所选的对象。这些对象不是在数据库中支持,所以它们并不真正具有每个说话的密钥。也许有一个更好的方法来做到这一点。

解决方案

如果你想获得实际的对象(像列表项或数据行),你不能在回发后(实际上,我不认为你可以在回发之前)。值将保存在所选项目属性中,但绑定对象将被丢弃。


I have an DropDownList bound to an ObjectDataSource. when I select a row in the drop down how do I get the underlying object(not just the value or text properties). I'm trying to add the selected object from the DropDownList to a Listbox's datasource but I don't know how to reference the object picked. The objects aren't backed in a database so they don't really have keys per say. Maybe there's a better way to do this.

解决方案

If you are trying to get the actual object (like a list item or data row), you can't after the postback (actually, I don't think you can before the postback either). The values are saved in the selected item property, but the bound object is discarded.

这篇关于DropDownList获取底层对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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