This is really challenging, i want to display three columns in a table,pls see the code iam using MVC and Razor.
here each item is rendered and displayed like this
Item1
Item2
item3
item4
item5
item6
my requirement i have to display it.
Item1 Item2 Item3
Item4 Item5 Item6
on every 3 row an tr should be inserted i guess,pls suggest me an solution sitting with this for two days.
My View:
@foreach(var item in Model.Products)
{
if(i%3==0)
{
}
else
{
}
i += 1;
}
Jaganathan BantheswaranPosted Oct 7, 2013, 10:17 AM
ashok kumarPosted Oct 7, 2013, 1:33 AM
Jaganathan BantheswaranPosted Oct 6, 2013, 1:53 AM
Try like this,
@foreach (var product in Model.Products) {
foreach(var item in product.rowItems) {
}
}
Restructure the Products collection
Product = {
rowName = "";
rowItems = new List() { "Item1", "Item2", "item3" }
}
Products = new List() { new Product(), new Product(), ........ }