locked
asp.net MVC Webgrid Action Column not working RRS feed

  • Question

  • User-434639980 posted

    I want to have two delete and edit Action Buttons in my webgrid together and in one column. But there is a problem,Help me, where is the problem؟!

    @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>
    

    https://i.stack.imgur.com/oeFNZ.png

    Tuesday, November 6, 2018 5:23 AM

Answers

  • User-434639980 posted

    problem solved. The modified codes are as follows

      @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))))

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 6, 2018 7:27 AM