因為改成分頁後會多一個Pager的Row
Pager的Row沒有Cells(2)跟Cells(3)所以會超出索引範圍
把程式改成這樣
看不清楚 | 列印 | 複製
1If e.Row.RowType = DataControlRowType.DataRow Then 
2    Dim str As String = "demand_info.aspx?id=" + Server.UrlEncode("歡迎光臨!!")  
3    e.Row.Cells(1).Text = "<a href=" + str.Trim + ">" + e.Row.Cells(1).Text + "</a>" 
4    e.Row.Cells(2).Text = "<a href=" + str.Trim + ">" + e.Row.Cells(2).Text + "</a>" 
5    e.Row.Cells(3).Text = "<a href=" + str.Trim + ">" + e.Row.Cells(3).Text + "</a>" 
6End If 
If e.Row.RowType = DataControlRowType.DataRow Then Dim str As String = "demand_info.aspx?id=" + Server.UrlEncode("歡迎光臨!!") e.Row.Cells(1).Text = "<a href=" + str.Trim + ">" + e.Row.Cells(1).Text + "</a>" e.Row.Cells(2).Text = "<a href=" + str.Trim + ">" + e.Row.Cells(2).Text + "</a>" e.Row.Cells(3).Text = "<a href=" + str.Trim + ">" + e.Row.Cells(3).Text + "</a>" End If