Click here to Skip to main content
14,877,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi to all,
Here i want to display country name from another table.


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

Here i using REPOSITORY PATTERN.and i'm new for mvc and repository pattern And i used Store Procedure
Updated 6-Sep-14 0:19am

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

Using Controls are Dropdownlist, RadioButtonList, DateTime Calender, FileUpload, Cascading Dropdown[^]
here i gave this but i got error

The data reader is incompatible with the specified 'Troy.Data.DataContext.user'. A member of the type, 'user_Id', does not have a corresponding column in the data reader with the same name. And i using store procedure and repository pattern
Hi you need to join your tables in your stored procedure:


Select * from yourtable1
ON yourtable1.country_id=country.country_id

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900