如何在mvc中显示另一个表中的国家/地区名称 [英] how to display country name from another table in mvc

查看:78
本文介绍了如何在mvc中显示另一个表中的国家/地区名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

这里我想从另一张桌子上显示国家名称。



描述:



在我的模块中,我有字段名country_id,另一个表(国家)有国家ID和



国名。在这里,我使用model.But在我的网格中完成下拉列表,它只显示国家ID。现在我的网格中我想显示国家/地区名称




如果有人不清楚请问我好。



请帮助我完成这项任务



重要提示:

这里我使用 REPOSITORY PATTERN 。我是mvc和存储库模式的新手我使用存储过程

hi to all,
Here i want to display country name from another table.

DESCRIPTION:

In my module i have field name country_id and another table(Country) have country id and

country name.Here i done dropdown to bind the name using model.But in my grid it show only country id .Now in my grid i want to show country name


If anybody not cleared Kindly ask me ok.

Kindly help me for this task

IMPORTANT:
Here i using REPOSITORY PATTERN.and i'm new for mvc and repository pattern And i used Store Procedure

推荐答案

在MVC上做了一篇文章,请通过这个查看底部描述,这样做。

代码应该是

In MVC did a article for this also please go through this and see on the bottom description, done this way.
Code should be
<td>
            @Html.DisplayFor(modelItem => item.CountryV.CountryName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.StateV.StateName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.CityV.CityName)
        </td> 



文章

使用控件是Dropdownlist,RadioButtonList,DateTime Calender,FileUpload,Cascading Dropdown [ ^ ]


查看

级联下拉列表,包含MVC,LINQ to SQL和AJAX [ ^ ]


您好需要在存储过程中加入表格:



例如:



从yourtable1中选择*

LEFT OUTER JOIN country

ON yourtable1.country_id = country.country_id
Hi you need to join your tables in your stored procedure:

example:

Select * from yourtable1
LEFT OUTER JOIN country
ON yourtable1.country_id=country.country_id


这篇关于如何在mvc中显示另一个表中的国家/地区名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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