目前的案子要通過無障礙a plus,所以大部份網頁要有停用js時的替代方案,遇到gridview時的替代作法。

無障礙空間 a plus

01
02     protected void GridView1_DataBound(object sender, EventArgs e)
03     {
04         if (this.GridView1.Rows.Count > 0)
05         {
06             GridViewRow pagerRow = this.GridView1.BottomPagerRow;   // 主要是這取得 pager row
07             //Label lbl = pagerRow.FindControl("lblTotalPage") as Label;
08             ((TextBox)pagerRow.FindControl("txtPage")).Text = now_page.Value;
09             ((Label)pagerRow.FindControl("lblTotalPage")).Text = total_page.Value;
10             ((Label)pagerRow.FindControl("lblTotalCount")).Text = total_count.Value;
11
12             if (now_page.Value == "1")
13             {
14                 ((Button)pagerRow.FindControl("lnkFirst")).Enabled = false;
15                 ((Button)pagerRow.FindControl("lnkPre")).Enabled = false;
16             }

17             else
18             {
19                 ((Button)pagerRow.FindControl("lnkFirst")).Enabled = true;
20                 ((Button)pagerRow.FindControl("lnkPre")).Enabled = true;
21             }

22
23             if (now_page.Value == total_page.Value)
24             {
25                 ((Button)pagerRow.FindControl("lnkLast")).Enabled = false;
26                 ((Button)pagerRow.FindControl("lnkNext")).Enabled = false;
27             }

28             else
29             {
30                 ((Button)pagerRow.FindControl("lnkLast")).Enabled = true;
31                 ((Button)pagerRow.FindControl("lnkNext")).Enabled = true;
32             }

33         }

34     }