I am trying to display like this
var value = "Kartheek@gmail.com"
@Html.DisplayName(value)
Result is : com only.
why? what have to use in this case
here i am explaining more
My intention is to display content in very generic with grid.
public class Grid
{
private Type type { get; set; }
public Grid(IEnumerable datasource)
{
if (datasource == null)
{
throw new ArgumentNullException("datasource");
}
this.type = datasource.GetType().GetGenericArguments().Single();
this.Data = datasource;
}
public IEnumerable Data { get; set; }
public IEnumerable<System.Reflection.PropertyInfo> Props
{
get
{
return this.type.GetProperties().AsEnumerable();
}
}
}
This is my c# class for grid. i am assigning values in to Grid.data and with viewbag i am sending grid data to view and then i am using this with in partial view
here my partial view code
@if (Model != null)
{
<table style="width: 100%">
<thead>
<tr>
@foreach (var col in Model.Props)
{
<th>@Html.Label(col.Name)</th>
}
</tr>
</thead>
<tbody>
@foreach (var item in Model.Data)
{
<tr>
@foreach (var prop in Model.Props)
{
var val = prop.GetValue(item, null).ToString();
<td>@Html.DisplayName(val)</td>
}
</tr>
}
</tbody>
</table>
}
Finally i got answer with this.. But i am not satisfied with that bcz there is another good solution for it.
var val = "kartheek@gmail.com";
<span>@val</span>