Reputation: 379
not experienced so bear with me.
I would like to use @Html.DisplayName
(or something similar) for a value in database, it works fine with a foreach loop. But is there a way to show a value from database with the id of the row?
Lets say I have this db on sql and I only want to display CusName of ID 3 with @Html.DisplayName
, is that possible orare there any alternatives to archieve this?
If possible please supply a working example, as I said im new so it is kinda confusing.
Upvotes: 0
Views: 86
Reputation: 2058
You can use linq query in view page and filter the id using where clause or you could filter out the value in controller and pass it directly to view.
@foreach (var item in Model.Where(c => c.ID == 3))
{
//use your html display name here
}
Upvotes: 1