Used by List <string> as a model in a web mesh in ASP.NET MVC3
2 answers
This is strange, but the explanation is that WebGrid is looking for the public properties of row objects to display them as columns; it so happens that Length is the only property that String returns .
Note that you can get the desired behavior by explicitly specifying the format :
@grid.GetHtml( columns: new[] { g.Column(format: (item) => item) } )
+2
@{ Boolean access = ViewBag.accesscontrols; } <h1 class="header_text_pink">Vendor Master List<img src='@Url.Image("~/content/images/question_mark.png")' alt="" class="information_icon" /></h1> <span>@Html.RenderNotificationMessage()</span> <div class="si_top_main_table" id="tableDiv_Arrays"> <div class="search_pink"> <div class="tablesorter_pink" id="targetContainer"> @{ List<FCC.POSS.Common.Models.Employee> listmodel = ViewBag.EmployeeList; ViewBag.Title = "Employee Master"; } @if (listmodel != null) { if (listmodel.Count > 0) { List<WebGridColumn> gridColumn = new List<WebGridColumn>(); var grid = new WebGrid(source: listmodel, rowsPerPage: listmodel.Count(), canSort: true, canPage: true); gridColumn.Add(grid.Column("Fname", header: "First Name")); gridColumn.Add(grid.Column("Lname", header: "Last Name")); gridColumn.Add(grid.Column("Address", header: "Address")); gridColumn.Add(grid.Column("City", header: "City")); gridColumn.Add(grid.Column("Phoneno", header: "Phone no")); gridColumn.Add(grid.Column("Passportno", header: "Passport no")); gridColumn.Add(grid.Column("Civilid", header: "Civil Id")); gridColumn.Add(grid.Column("Gender", header: "Gender")); gridColumn.Add(grid.Column("Createddt", header: "Created Date")); gridColumn.Add(grid.Column("Deleteddt", header: "Deleted Date")); gridColumn.Add(grid.Column("Isdelete", header: "Is Deleted ?")); // gridColumn.Add(grid.Column("View", format:@<text><span style=" background- color:Blue; color:Green">@Html.ModalDialog("View","ag",null,Url.Action("Details","Employee",new {item.Id}),false)</span></text>)); @grid.GetHtml( tableStyle:"display tablesorter_usermaster", columns:grid.Columns(gridColumn.ToArray()), htmlAttributes: new { id = "mst_WebGrid", @style = "width:100%;" }); } } </div> </div> </div> <h2>Index</h2>
0