谁能给我解释一下ViewState?
我是在看到演练中 DataGrid的分页中 使用到的:
private void FillGrid(System.Data.SqlClient.SqlCommand currentSqlCommand)
{
System.Data.SqlClient.SqlDataReader dr;
sqlConnection1.Open();
dr = currentSqlCommand.ExecuteReader();
DataGrid1.DataSource = dr;
DataGrid1.DataBind();
dr.Close();
sqlConnection1.Close();
ViewState["CurrentPage"] = CurrentPage;//??
ViewState[CurrentPage.ToString()] = DataGrid1.Items[0].Cells[0].Text;//----------------------------------??
// Determine how many rows were filled into the grid. If it is less
// than the number of rows per page, there are no more rows in the
// table, and the Next button should be disabled.
if (DataGrid1.Items.Count < DataGrid1.PageSize)
{
btnNext.Enabled = false;
}
}