微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 MVC ASP NET 中显示 webgrid 的问题

如何解决在 MVC ASP NET 中显示 webgrid 的问题

我需要从使用 MysqL 数据库数据库表和使用 ASP NET MVC 的视图模型获得的值填充两个 DropDownList。

在填充 DropDownList 之后,我需要使用在单个 DropDownList 上选择的值过滤 WebGrid。

有了这个控制器部分

public ActionResult RecoveryAll()
{
    PersonModel model = new PersonModel();
    model.Dates_List = PopulateDates(null); //First DDL
    model.Ticket_List = PopulateTkt(null);  //Second DDL
    return View(model);
}

[HttpPost]
public ActionResult RecoveryAll(string country)
{
    PersonModel model = PopulateModel(country);
    return View(model);
}

private static PersonModel PopulateModel(string country)
{
    PersonModel model = new PersonModel();
    return model;
}

回来时我有

enter image description here

现在我需要显示 WebGrid 并将视图编辑为

@webGrid.GetHtml(
    htmlAttributes: new { @id = "WebGrid",@class = "Grid" },columns: webGrid.Columns(
             webGrid.Column("CustomerID","Customer Id"),webGrid.Column("ContactName","Customer Name"),webGrid.Column("City","City"),webGrid.Column("Country","Country")))

但是如何编辑用于显示 WebGrid 的控制器?

因为现在在visual studio 2019上调试我有这个错误

您必须绑定数据源才能执行此操作

帮我做。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。