剛好有人看到這篇 然後提出了以下疑問
(其他程式部分請參照上篇 這邊只挑重點部分來講)
HI~坎尼 我想請問 如果想讓上下方同時都有分頁的效果 是要設定 Gridview.PagerSettings.
那上方的下拉選單跳頁SelectedIndexChanged 該如何指定
因為上方的DropDownList 是要取TopPagerRow的FindControl 就無法共用同一個SelectedIndexChanged
而我目前測試的結果Grid 似乎不能有兩個PagerTemplate來區分上下的下拉選單
麻煩坎尼解答一下~3q
這邊的解法算還蠻簡單的 (其實是坎尼之前的寫法不太對
首先 先將 Gridview 裡 Page Settings 的 Position 設定為 TopAndBottom

在設計畫面上就會看到以下的畫面

再來就是 PageSet 方法裡 加入 TopPagerRow 的 DropDownList 相關設定
這邊要注意一下 如果沒開啟 TopPagerRow 可是會出現 Exception


最後是坎尼當時沒寫好的地方 跳頁事件
這邊只要很簡單的把傳進來的 sender 轉型即可
再將 Gridview 的 PageIndex 設定為所選的 index

大功告成

這邊可以看到 上下的自訂分頁長的不太一樣
這是坎尼故意做的區別 如果要做到上下都相同的話
則要把下圖圈起來的地方 加上找尋 TopPagerRow 裡的 Label 的動作

另外坎尼還是不曉得 直接回意見能不能貼圖? 囧>
坎尼對 blog 的撰寫還是沒啥 sense
1 則留言:
不要再用 Hungarian Notation 了啦~
除非是維護舊的程式不得已,不然還是用 Pascal Case / Camel Case 比較好,
反正現在 IDE 很方便,滑鼠移過去就知道 Data Type 了~
張貼留言