3
Answers

How to display three columns in a table in MVC

Ask a question
ashok kumar

ashok kumar

10y
1.6k
1
Hi 
   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)
        {

              
              <img src="data:image;base64,@System.Convert.ToBase64String(item.PRoductImage)" height="10px" width="200px" id="test" onclick="testing();" />
                    
             
              <button id="btn" type="button" title="BTN" onclick="Add(@item.Id);"></button>
                     
         
   
    }
    else
        {
          
             
               <img src="data:image;base64,@System.Convert.ToBase64String(item.PRoductImage)" height="10px" width="200px" id="tests" onclick="testing();" />
                    
             
              <button id="btns" type="button" title="BTN" onclick="Add(@item.Id);"></button>
                 
          
        }

      

    
        i += 1;

    } 




Answers (3)