Abraham Olatubosun

Abraham Olatubosun

  • NA
  • 471
  • 114.5k

How to display records in Rows in ASP.NET MVC5

Dec 20 2017 1:29 PM
Dear all,
 
   Compliment of the season, I am prety new to ASP.NET MVC but when through some tutorials and i am able to get my fingers on it step by step.
 I have some issue with the displaying my records in rows  below is my code from the Index.cshtml
  1. @model System.Data.DataTable  
  2. @{  
  3.     ViewBag.Title = "Index";  
  4. }  
  5.   
  6. <table class="table table-bordered table-striped table-responsive">  
  7.     <tr>  
  8.         <th>First Name</th>  
  9.         <th>Last Name</th>  
  10.         <th>Other Name</th>  
  11.         <th>Email</th>  
  12.         <th>Address</th>  
  13.         <th>B Month</th>  
  14.         <th>Martal Status</th>  
  15.         <th>Member Status</th>  
  16.         <th>  
  17.             Edit  
  18.         </th>  
  19.         <th>  
  20.             Delete  
  21.         </th>  
  22.   
  23.          
  24.     </tr>  
  25.     <tr>  
  26.       
  27.         @for (int i = 0; i < Model.Rows.Count; i++)  
  28.         {  
  29.             <td>@Model.Rows[i][1]</td>  
  30.             <td>@Model.Rows[i][2]</td>  
  31.             <td>@Model.Rows[i][3]</td>  
  32.             <td>@Model.Rows[i][4]</td>  
  33.             <td>@Model.Rows[i][5]</td>  
  34.             <td>@Model.Rows[i][6]</td>  
  35.             <td>@Model.Rows[i][7]</td>  
  36.             <td>@Model.Rows[i][8]</td>  
  37.             <td><a class="btn btn-primary" href="@Url.Action("Edit", "Member", new {@[email protected][i][0] })" >Edit</a></td>  
  38.             <td><a class="btn btn-danger" href="@Url.Action("Delete", "Member", new {@[email protected][i][0] })">Delete</a></td>  
  39.         }  
  40.     </tr>  
  41.      
  42. </table>  
  43.   
  44. <a href="@Url.Action("Create","Member")" class="btn btn-sm btn-primary">Add Member</a>  
  45.   
  46. @*<button id="my-button" onclick="location.href='@Url.Action("YourActionName", "YourControllerName")'">Submit</button>*@  
 my Model code is as follows (I am not using Entity Frame work)
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Linq;  
  5. using System.Text;  
  6. using System.Threading.Tasks;  
  7.   
  8. namespace HIGHGROUNDMCV.Models  
  9. {  
  10.   public   class MembersModel  
  11.     {  
  12.         public int ID { getset; }  
  13.       [DisplayName("First Name")]  
  14.         public string FName { getset; }  
  15.       [DisplayName("Last Name")]  
  16.         public string  LName { getset; }  
  17.       [DisplayName("Other Name")]  
  18.         public string  OName { getset; }  
  19.         public string  Email { getset; }  
  20.         public string  Address { getset; }  
  21.       [DisplayName("Month of Birth")]  
  22.         public int MOB { getset; }  
  23.       [DisplayName("Marital Status")]  
  24.         public string  MStatus { getset; }  
  25.       [DisplayName("Member Status")]  
  26.         public string  MembStatus { getset; }  
  27.     }  
  28. }  
then the result i am getting is as follows 
 
 
 I want the records to show in rows all show in a single row, please what am i doing wrong.
 
thank you for your help 
 
 

Answers (4)