【问题标题】:asp.net MVC Webgrid Action Column not workingasp.net MVC Webgrid 操作列不起作用
【发布时间】:2023-03-22 02:46:02
【问题描述】:

我想在我的 webgrid 中将两个删除和编辑 َAction 按钮放在一起并放在一列中。但是有个问题,帮帮我,问题出在哪里!

@ModelType IEnumerable(Of Machinary.Brand)
@Code
    Dim wg As New WebGrid(Model, rowsPerPage:=10, canPage:=True, canSort:=True, ajaxUpdateContainerId:="wg1")
    Dim rowIndex = ((wg.PageIndex + 1) * wg.RowsPerPage) - (wg.RowsPerPage - 1)
End Code
<section Class="panel">
    <br />
    <header Class="panel-heading">Brands</header>
   
    <div Class="panel-body pull-left">
        @Using (Html.BeginForm("BrandList", "Home", FormMethod.Get))
            @Html.TextBox("strName", Nothing, New With {.class = "form-control", .PlaceHolder = "جستجو"})
                @<Button type="submit" value="" style="display: none"></Button>
        End Using

    </div>
  
    <div>
        
        @wg.GetHtml(tableStyle:="table table-bordered table-hovor", mode:=WebGridPagerModes.All,
                          htmlAttributes:=New With {.id = "wg1", .class = "Grid"},
                          firstText:="<<",
                          lastText:=">>",
                          footerStyle:="table-pager",
                          columns:=
                          wg.Columns(wg.Column("Name", "Title"),
                          wg.Column(header:="Actions", format:=Function(item) New HtmlString() {
                          Html.ActionLink("Edit", "Edit", New With {.id = item.id}),
                          Html.ActionLink("Delete", "Delete", New With {.id = item.id})})))
    </div>
</section>

This image shows the code output

【问题讨论】:

    标签: asp.net-mvc webgrid


    【解决方案1】:

    问题解决了。修改后的代码如下

      @wg.GetHtml(tableStyle:="table table-bordered table-hovor", mode:=WebGridPagerModes.All,
                                                   htmlAttributes:=New With {.id = "wg1", .class = "Grid"},
                                                   firstText:="<<",
                                                   lastText:=">>",
                                                   footerStyle:="table-pager",
                                                   columns:=
                                                   wg.Columns(wg.Column("Name", "Title"),
                                                   wg.Column(header:="Actions", format:=Function(item) New HtmlString(
                                                   Html.ActionLink("Edit", "Edit", New With {.id = item.id}).ToString +
                                                   Html.ActionLink("Delete", "Delete", New With {.id = item.id}).ToString))))
    

    【讨论】:

      猜你喜欢
      • 2011-12-07
      • 2018-03-12
      • 1970-01-01
      • 2021-05-24
      • 1970-01-01
      • 2018-03-17
      • 1970-01-01
      • 2013-01-07
      • 2016-12-16
      相关资源
      最近更新 更多