Sasi Reddy

Sasi Reddy

  • NA
  • 346
  • 164.3k

webgrid with Tuple

Mar 27 2014 1:44 AM
This is my Controller
public ActionResult PatientEnquiries()
        {
          


            var k = from p in db.MPatientRegistrations
                    join p1 in db.PatientComplaints on p.PatientId equals p1.PatientId
                    join p2 in db.PDoctorSelections on p.PatientId equals p2.PatientId

                    select new
                    {
                        name = p.Name,
                        Age = p.Age,
                        MobileNo=p.MobileNo,
                        complaint=p1.Complaint,
                        Request=p1.Request,
                        Id=p2.DoctorId
                     
                    }; 


            return View(k.ToList());

          

        }

This is my view

@{
    
        Layout = "../Shared/_DoctorRegistration.cshtml";
 
    
  
}
 <div class="mainbar1" style="height :500px;width:auto; overflow: auto;" align="center">
     @{
    var grid = new WebGrid(Model, canPage: true, rowsPerPage:3, 
    selectionFieldName: "selectedRow",ajaxUpdateContainerId: "gridContent");
        grid.Pager(WebGridPagerModes.NextPrevious);} 

     <div class="webGrid">         
                           
    @grid.GetHtml(tableStyle: "webGrid",
            headerStyle: "header",
            alternatingRowStyle: "alt",
            selectedRowStyle: "selectedrow",
          
            columns: grid.Columns(
          
            
         grid.Column("Name","Name"),
         grid.Column("Age","Age"),
          grid.Column("MobileNo","MobileNo"),
            grid.Column("complaint","complaint"),
           grid.Column("Request","Request"),
             grid.Column("Id","Id")
                    
   
          
                                                                          
     )) 
      </div >
 </div>

I got the answer by using above code