ASP.net MVC如何获取ID字段的项目列表的价值呢? [英] ASP.net MVC how to get the value of the ID field for the list of items?

查看:110
本文介绍了ASP.net MVC如何获取ID字段的项目列表的价值呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,显示绑定到类型化模式的产品清单。

I have an application, that shows list of items bound to a typed model.

在列表中每个项目都有从查找表的ID。

In the list every item has an ID from a lookup table.

如何显示的查找数据的值的每个项目,而不是编号

How to show the value of the lookup data for each item instead of IDs?

最好的办法有一个HTML链接的DropDownList每个ID,从我能选择合适的值,其中

The best way has to link a html dropdownlist to each ID, from where I would be able to choose the appropriate value.

在此先感谢

Gabrile

推荐答案

嘛第一步是确保你得到所有将要在DropDownList中的值。你应该能够轻松地从数据库中获取这一点。

Well the first step is to make sure you get all of the values that will be in the DropDownList. You should be able to easily fetch this from your database.

将DropDownList的项目为查找项的文本值的文本,并将其值设置为这些相同的项目的ID。

Set the text of the DropDownList items to the text value for the lookup item, and set the value to the ID of those same items.

在创建的DropDownList请务必将选定一个是,你的建模的数据项的ID相匹配的选项。

When creating the DropDownList make sure to set the Selected one to be the option which matches the ID of your modeled data item.

这篇关于ASP.net MVC如何获取ID字段的项目列表的价值呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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