在ASP.NET Core中使用WebGrid

编程入门 行业动态 更新时间:2024-10-27 23:27:25
本文介绍了在ASP.NET Core中使用WebGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在ASP.NET Core应用程序中使用System.Web.Helpers.WebGrid控件, 渲染网格时出现以下错误

I am using System.Web.Helpers.WebGrid control in ASP.NET Core application, I am getting the below error while rendering the grid

An unhandled exception occurred while processing the request. ArgumentNullException: Value cannot be null. Parameter name: httpContext System.Web.HttpContextWrapper..ctor(HttpContext httpContext)

在线

System.Web.Helpers.WebGrid objWebGrid = new System.Web.Helpers.WebGrid(Model.MeetingsObj);

型号:

public class Meeting { public int MeetingId { get; set; } public string MeetingName { get; set; } public string Format { get; set; } public string Location { get; set; } } public class MeetingVM { public Meeting MeetingObj { get; set; } public List<Meeting> MeetingsObj { get; set; } public Boolean ShowGridHeader { get; set; } }

任何人都可以为上述错误提供解决方案吗?

Can anyone provide solution for the above error?

推荐答案

您可以尝试使用其他组件,我建议使用MVC6网格 mvc6-grid.azurewebsites/

You may try to use another component , i recommend the MVC6 grid mvc6-grid.azurewebsites/

基本上使用几乎相同的语法,因此您当前的代码将有少量更改,请检查下面的示例代码

basically it use almost same syntax ,so there will be minor changes to your current code ,please check the below sample code

@model IEnumerable<PersonModel> @(Html .Grid(Model) .Build(columns => { columns.Add(model => model.Name).Titled("Name"); columns.Add(model => model.Surname).Titled("Surname"); columns.Add(model => model.Age).Titled("Age"); columns.Add(model => model.Birthday).Titled("Birth date"); columns.Add(model => model.IsWorking).Titled("Employed"); //popup part columns.Add(model => $"<a data-modal='' data-id=\"{model.Id}\" href='PasswordRestUser/{model.Id}' id=\"ss\" asp- action=\"PR\" asp-route-id=\"@item.Id\" class=\"btn btn-info\" '> PR <span class='glyphicon glyphicon-user'> </span> </a>").Encoded(false); }) .Filterable() .Sortable() .Pageable() ) <div id='myModal' class='modal fade in'> <div class="modal-dialog"> <div class="modal-content"> <div id='myModalContent'></div> </div> </div> </div>

它还具有许多其他功能,这些功能使core变得更容易

it also has many other features that will make thing easier with core

更多推荐

在ASP.NET Core中使用WebGrid

本文发布于:2023-11-04 11:24:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557799.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:NET   ASP   WebGrid   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!