Click here to Skip to main content
15,905,682 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.

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
Posted
Updated 6-Sep-14 0:19am
v4

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> 

Article
Using Controls are Dropdownlist, RadioButtonList, DateTime Calender, FileUpload, Cascading Dropdown[^]
 
Share this answer
 
Comments
JOTHI KUMAR Member 10918227 6-Sep-14 6:18am    
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
 
Share this answer
 
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
 
Share this answer
 

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