0

我在部分視圖中顯示動態選擇的列作爲網格(使用webgrid)。當我在局部視圖webgrid上執行分頁時,該局部視圖網格單獨在新頁面中再次加載。我想要分頁視圖的分頁,而不會將partialview單獨重定向到newpage。部分視圖中的分頁

+0

你能提供你的代碼的一個片段嗎?鑑於我還沒有看到您的代碼,我認爲您可以使用@@ Ajax幫手而不是@@ Html的方法來實現您的目標 –

+0

@{ var grid1 = new WebGrid(Model.oTravelReadyEntities, canPage: true, rowsPerPage: 3,ajaxUpdateContainerId:"result"); grid1.Pager(WebGridPagerModes.NextPrevious); @grid1.GetHtml(tableStyle: "WebGrid", headerStyle: "Header", alternatingRowStyle: "alt", columns: ViewBag.Columns) }
user2514925

回答

0

從您提供的代碼判斷,您似乎將ajaxUpdateContainerId設置爲「result」,但在頁面上沒有任何與該id相關的控件,您可以通過提供HtmlAttributes在.GetHtml()方法中設置該id。

所以編輯行會是這個樣子:

@grid1.GetHtml(htmlAttributes: new { id="result" },tableStyle: "WebGrid", headerStyle: "Header", alternatingRowStyle: "alt", columns: ViewBag.Columns) 

請檢查this link更多細節

+0

非常感謝。它現在工作正常。 – user2514925

+0

@ user2514925沒問題,我很高興我可以幫忙:) –