I am passing ViewBag like,
var forms = SqlMapper.Query(con, "getDetails", param, commandType: CommandType.StoredProcedure);
ViewBag.myForm = forms;
This 'forms' contains values like VehicleType, VehicleName, VehiclePrice and I am displaying those in the view using loop,
@foreach (var frm in ViewBag.myForm)
{
<div class="form-group">
<label for="exampleInputEmail1">@frm.VehicleType</label>
<label for="exampleInputEmail1">@frm.VehicleName</label>
<label for="exampleInputEmail1">@frm.VehiclePrice</label>
</div>
}
This works fine. Now I want to display VehicleType in the header as well. And I don't want to loop the ViewBag again to get the VehicleType. VehicleType will be same for the list. Like if I get 'Car' as VehicleType, then for that ViewBag, 'Car' is the only VehicleType. How can I read VehicleType without looping ViewBag? Thanks
To get more idea on data,
Vehicle Type | Name | Price
Car | Ford | 1000000
Car | Audi | 1500000
Car | Chev.| 1250000
Car | Volks| 1246000
I want to display the Vehicle type,
<div class="box-header with-border">
<h3 class="box-title">@ViewBag.myForm ----- VehicleType</h3>
</div>