Question

I am facing the issue , i want to display two Webgrid in one view , so i create separate view for each , and calling on one view using

 <table>
   <tr>
    <td>
        @{Html.RenderAction("NewRegisterCustomer", "AdminDeshboard");}
        @{Html.Action("NewRegisterCustomer", "AdminDeshboard");}
    </td>
  </tr>
  <tr>
    <td>
         @{Html.RenderAction("OrderSummary", "AdminDeshboard");}
        @{Html.Action("OrderSummary", "AdminDeshboard");}
    </td>
  </tr>

both Webgrid showing properly but when i change the page one Webgrid another Webgrid also effected

this is my Webgrid code

    <fieldset>
    @{
    ViewBag.Title = "WebGrid with Custom Paging, Sorting";
    WebGrid grid1 = new WebGrid(rowsPerPage: Model.PageSize);
    grid1.Bind(Model.Order,
              autoSortAndPage: false,
              rowCount: Model.TotalRows
    ); 
   }
     @grid1.GetHtml(
     fillEmptyRows: false,
     alternatingRowStyle: "alternate-row",
     headerStyle: "grid-header",
     footerStyle: "grid-footer",
    mode: WebGridPagerModes.All,
    firstText: "<< First",
    previousText: "< Prev",
     nextText: "Next >",
    lastText: "Last >>",


   columns: new[] {

    grid1.Column("OrderId",header: "  OrderId    ",style:"Width=100px"),
    grid1.Column("FirstName",header: "  FirstName    "),
    grid1.Column("LastName",header: "  LastName     "),
    grid1.Column("CartTotal",header: "  CartTotal    ",style:"Width=100px")

  })
 </fieldset>

when i change page url like this localhost:49424/HomeAdmin?page=2 it effect on both grid ,

There is any way so i change the page name

   **page ---> Orderpage** 

Please guide me

Thanks

Était-ce utile?

La solution

This is what the fieldNamePrefix parameter in the WebGrid Constructor is for.

From the documentation:

fieldNamePrefix

Type: System.String

The prefix that is applied to all query-string fields that are associated with the WebGrid instance. This value is used in order to support multiple WebGrid instances on the same web page.

Or if you just want to change the paging field name, there's a parameter for that (as there is for selections, sort fields and sort direction).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top