0

The first time I do paging it works fine. When I place the cursor over footer paging, it looks like

http://localhostt:62535/Account/Index?page=3

If I perform any operation on WebGrid (edit or delete or visible), then the paging url is changed to something like

http://localhostt:62535/Account/VisibleCountry?Id=101&page=3

code

@{
    ViewBag.Title = "Index";
        Layout = "~/Views/Shared/User.cshtml";
    WebGrid grid = new WebGrid(Model.OrderBy(m=>m.idVal), canSort: true, canPage: true, rowsPerPage: 20,
    selectionFieldName: "selectedRow", ajaxUpdateContainerId: "stategrid");
}



 <div id="countrygrid" align="center">

    @grid.GetHtml(tableStyle: "webGrid",
    headerStyle: "header",
    alternatingRowStyle: "alt",
    selectedRowStyle: "select",
    columns: new[] {
        grid.Column("CountryName","Country Name"),
        grid.Column("",header:"Action",format:@<text>
            @Html.ActionLink("Edit", "Edit", new {  id=item.CountryId })
            |
            @if (item.deleted == false)
            {
                 <a href="#?id=@item.CountryId" onclick="changeCountry(this)" title="Disable">Disable</a> 
            }
            else
            {
                <a href="#?id=@item.CountryId" onclick="ChangeCountry(this)" style="color:red" title="Enable">Enable</a> 
            }
        </text>),

        grid.Column("",header:"Action",format:@<text><a href="#"  id="@item.CountryId"  class="countryIdValues" >Addstate</a></text>)
    });

</div>

I am not understanding why the url is changing. Can any one help me with this?

Josh Durham
  • 1,632
  • 1
  • 17
  • 28
Ram
  • 337
  • 5
  • 23

1 Answers1

0

It seems you are using Async postback using JQuery to perform other action like Edit/Delete/... You can do below to workatound,

Reset your page using Ajax after every other actions e.g Edit/Delete/... e.g Trigger reset event in JS function like this

  $("#resetid").click();

  <input type="reset" id="resetid" value="Reset" name="Reset"/>

or if you don't have reset event then try to reload the ajax call/page.

It worked for me, hope this helps.!!!