Hi buddies,

I am new in .net and I have populate data in dataset and also in datagrid now
On click of PageIndex of Datagrid , my code enter DataGrid1_PageIndexChanged event in alternate fashion. It means when i click on 2 it does not show the record but when i click on 3 then it
show the record od 2nd page index. Can anubody tell mw why is this happening. I have search a lot for this but nor able to find the exact solution.
Please Help me out of this.


protected System.Web.UI.WebControls.DataGrid DataGrid1;
private DataSet catDS;
private void Page_Load(object sender, System.EventArgs e)
{
if (Page.IsPostBack ==false )
{
PopulateGrid();
DataGrid1.DataSource = catDS;
DataGrid1.DataBind();
}
}

private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
PopulateGrid();
DataGrid1.CurrentPageIndex = e.NewPageIndex ;
DataGrid1.DataSource = catDS;
DataGrid1.DataBind();

}

private void PopulateGrid()
{
SqlConnection nwindConn = new SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind");

SqlDataAdapter catDA = new SqlDataAdapter("SELECT CategoryID, CategoryName,description FROM Categories", nwindConn);

nwindConn.Open();

catDS = new DataSet();
catDA.Fill(catDS, "Categories");


nwindConn.Close();


}

}