Tag: webgrid

WebGrid的标头格式

我刚刚阅读: http : //www.mikesdotnetting.com/Article/154/Looking-At-The-WebMatrix-WebGrid并查看对[Optional, Default Value(null)] string header的引用 如果您不想要数据库字段名称,则为标题文本 但我不确定如何格式化单元格值。 例如,如果我有一个如下所示的WebGrid: Column Name Column Name Column Name Column Name Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value Cell value […]

在C#中解析动态SQL并在ASP.Net MVC中绑定到WebGrid

在C#中解析动态SQL并在ASP.Net MVC中绑定到WebGrid我有动态SQL查询,它使用pivot来生成结果,结果集可能是这样的: Name Div1 Div2 Div3 Div4 Div5 Active 1 0 0 0 0 Busy 0 0 0 0 1 NA 0 1 0 0 0 Suspended 0 0 0 1 0 可以有n个分区。 我想将此数据与ASP.NET MVC WebGrid控件绑定。 我无法做到这一点。 我的C#代码如下: dynamic list = db.ExecuteStoreQuery(“exec [dbo].[proc_GetData]”).ToList(); return list; 我想将此列表与ASP.NET MVC Webgrid绑定,我的webgrid代码如下: WebGrid grid = new WebGrid(Model.DataList); List list […]

是MVC WebGrid开源吗?

是MVC WebGrid开源吗? 如果是这样,我在哪里可以找到源代码。 WebGrid的当前版本几乎没有文档,不完整的实现等。 我试图做一个简单的事情,就是在视图中向WebGrid.Column()添加一个visibility属性,但这是不可能的

ASP.NET MVC 3 WebGrid分页问题

我的数据访问层返回带有单页行数和总行数的集合。 遗憾的是,WebGrid组件不允许指定总行数或总页数(这些属性是只读的)。 以前有人不得不处理这个问题吗?

在.NET 4.0中,WebGrid + Paging + Sorting + Filtering中的filter丢失了

我已经实现了一个WebGrid。 排序,分页和过滤不能一起使用。 它们在您单独使用时起作用。 当您将三者结合使用时,过滤不起作用。 症状: 过滤结果集,然后排序。 要么 过滤结果集,然后转到下一页。 在这两种情况下,filter都会丢失。 但它确实是页面和排序。 在后面的代码中:当通过排序或分页调用action方法时,为每个filter参数显示null。 通过filter调用操作方法时,filter参数会通过。 这告诉我,当你开始排序或分页时,它没有提交表单。 public ActionResult MyPage(int? page, int? rowsPerPage, string sort, string sortdir, string orderNumber, string person, string product) 我在SO和其他地方环顾四周。 有很多例子和人们都在询问如何做一个或另一个或全部三个。 但我只看到一个与我的问题 ,所以我在这里发布。 (他也没有解决) 我的页面实现如下: @using (Ajax.BeginForm(“MyPage”, null, new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = “myGrid” }, new { id = “filter” })) { […]

ASP.NET MVC3 WebGrid格式:参数

我试图在ASP.NET MVC3中使用新的WebGrid,并且我希望显示一组链接图标,执行各种操作(编辑,查看,删除)……为此,我有一个HtmlHelper扩展,基本上输出HTML: 扩展返回MvcHtmlString,它在Razor视图中单独使用时工作正常.Eg:@ Html.ActionLinkIconForEditAction(“Customer”,2) 问题是我需要在传递对象的ID时在WebGrid列中调用此帮助程序(每个操作一次)。 我难以理解的问题是编译器给我一个错误,说它无法将MvcHtmlString(或’lambda expression’取决于我尝试的调用)转换为格式预期的System.Func … 例如,这有效: grid.Column(header: “”, format: @@Html.ActionLinkIconForEditAction(“Customer”, 2)) 但这不是: grid.Column(header: “”, format: (customer) => @@Html.ActionLinkIconForEditAction(“Customer”, customer.Id)) grid.Column(header: “”, format: (customer) => Html.ActionLinkIconForEditAction(“Customer”, customer.Id)) 我明白了: Error 4 Argument 3: cannot convert from ‘lambda expression’ to ‘System.Func’ 或者这个电话: grid.Column(header: “”, format: Html.ActionLinkIconForEditAction(“Customer”, customer.Id)), 我明白了: Error 5 Argument 3: cannot convert from […]

绑定WebGrid表单AJAX

我是MVC3和Razor的新手,一旦从AJAXpost返回数据,我需要帮助绑定/加载WebGrid。 真的很感激任何帮助(项目到期日快速接近);) 我的情况是这样的:我有两个级联下拉列表。 第一个列表包含数据库中的区域。 选择一个区域后,它会使用一系列设施填充第二个下拉列表。 选择设施后,我需要使用建筑物列表填充WebGrid。 我有级联下拉正常工作 Index.cshtml: @using ThisController = MyProject.Controllers.BuildingModelsController @model IEnumerable @{ if (Model != null && Model.Count() > 0) { var grid = new WebGrid(source: Model, rowsPerPage: ThisController.PageSize, ajaxUpdateContainerId: “tabs-2”, defaultSort: “BuildingNumber”); grid.Bind(Model, rowCount: Model.Count(), autoSortAndPage: false); grid.Pager(WebGridPagerModes.All); grid.GetHtml( tableStyle: “display”, alternatingRowStyle: “alt”, columns: grid.Columns( //grid.Column(format: (item) => Html.ActionLink(“Edit”, “Edit”, new […]

在WebGrid.column中使用HTML.ActionLink中的数据是不可能的?

我的ASP.NET MVC3测试应用程序中有以下WebGrid。 它显示了一个客户列表: @grid.GetHtml( tableStyle: “grid”, headerStyle: “head”, alternatingRowStyle: “alt”, columns: grid.Columns ( grid.Column(format: (item) => Html.ActionLink(“Edit”, “Details”, new { id = item.id })), grid.Column(“Address.CompanyName”), grid.Column(“Address.City”) ) ) 这里有趣的部分是我在第一列中添加的编辑链接。 我想使用客户帐号而不是简单的“编辑”测试。 但是,这给我带来了很多问题。 我试过了: grid.Column(format: (item) => Html.ActionLink(item.AccountNumber.ToString(), “Details”, new { id = item.id })), 但是,似乎有些东西我不明白这是如何工作的,因为我一直得到这个例外: CS1502: The best overloaded method match for ‘System.Web.Helpers.WebGrid.Column(string, string, System.Func, string, […]