這是彈出一個異常,說我不能在服務器端使用分頁。將數據綁定到gridview。如何使用分頁?
conn.Open();
string querstring = "select * from gt_transaction_log where LogTimeStamp between '2013-09-19 07:06:00.077' and '2013-09-19 10:28:25.163' ";
SqlCommand cmd = new SqlCommand(querstring, conn);
GridView1.EmptyDataText = "no record found";
GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();
GridView1.AllowPaging = true;
GridView1.PageSize = 5;
嘗試最後兩個命令移動DataBind方法上面。 –
查看此示例:http://msdn.microsoft.com/en-us/library/aa479347.aspx –