I have one action in my controller :
public ActionResult GiftVochure()
{
if (Request.QueryString["gc"] != "")
{
var obj = from b in context.GiftCards
join cus in context.Customers on b.CustomerID equals cus.ID
where b.ID == int.Parse(Request.QueryString["gc"])
select new
{
b.ID,
b.Date,
b.CardNo,
b.Price,
CustomerName = cus.FirstName + " " + cus.LastName
};
return View(obj.ToList());
}
return View();
}
And I want to take “obj” to loop and display in the GiftVochure Views, Does any one know, how to do this?
Thanks.
You should start by defining a model type to replace the anonymous type projected by the query.
Modifying your action method:
Then you should strongly type your GiftVochure view to this type’s sequence.
In the end you can iterate the items in your view.
You should probably move your markup for displaying a single object to a partial view. Then render it in your loop.