Announcement

Collapse
No announcement yet.

Webgrib trên MVC4

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Webgrib trên MVC4

    cho mình hỏi về webgrib trên mvc4 .
    cơ bản là thế này mình tạo 1 database
    create table data
    (
    id int primary key not null,
    ten varchar(20) null,
    ho varchar (20) null
    )
    ###model:
    public class datagrid
    {
    public int id { get; set; }
    public string ten { get; set; }
    public string ho { get; set; }

    }
    ####controller

    public ActionResult Index()
    {

    using(datagridContext db=new datagridContext())
    {
    var lst = db.data.ToList();
    return View(lst);
    }

    }
    ####view:

    @model IEnumerable<datagrid.Models.datagrid>
    @{
    ViewBag.Title = "Index";
    }

    <h2>Index</h2>
    @{
    var webgrib = new WebGrid(Model, rowsPerPage: 10, defaultSort: "id", columnNames: new[] { "id", "ten", "ho" });

    }
    @webgrib.GetHtml(
    fillEmptyRows:false,
    mode:WebGridPagerModes.All,
    columns:webgrib.Columns
    (
    webgrib.Column("id",header:"id"),
    webgrib.Column("ten",header:"ten"),
    webgrib.Column("ho",header:"ho")
    ))
    khi debug thì bị báo lỗi


    The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[datagrid.datum]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[datagrid.Models.datagrid]'.

    các bạn xem giúp mình với

LHQC

Collapse
Working...
X