分页显示的问题
下列代码实现分页显示怎么不成功?
string conString = "server = (local);database = pratice;user id = sa; pwd = ";
SqlConnection myConnection = new SqlConnection(conString);
SqlDataAdapter myCommand = new SqlDataAdapter(sqlString,myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds,"unformatdata");
this.DataGrid1.PageSize = 5;
//this.DataGrid1.PageSize = System.Convert.ToInt16(this.DropDownList1.SelectedItem.Value);
//this.DropDownList1.Items.FindByValue(this.DataGrid1.PageSize.ToString()).Selected = true;
if (ds.Tables["unformatdata"].Rows.Count == 0) //没有找到记录
{.....}
else{
DataGrid1.DataSource = ds.Tables["unformatdata"];
DataGrid1.DataBind();
this.Lab_Count_A.Text = "第"+System.Convert.ToString(DataGrid1.CurrentPageIndex+1)+"页/共"+this.DataGrid1.PageCount.ToString()+"页";
this.Lab_Count_B.Text = "第"+System.Convert.ToString(DataGrid1.CurrentPageIndex+1)+"页/共"+this.DataGrid1.PageCount.ToString()+"页";
}
开始用的注释的语句,试验不行,后来改用其上面一句说明DataGrid1.PageSize 值
为什么明明DataGrid1记录数超过5还是不分页。谢谢!