datagrid view paging problem
<p>Iam using datagridview for displaying data ans it has 3000 records.</p>

<p>in button click iam calling</p>

<pre><code>   protected void btnSync_Click(object sender, EventArgs e)
    {
        DataTable datatable1 = new DataTable();
        try
        {
            dtUserName = oFTE.GetUserNames();
            Cache.Add("FTEUsers", dtUserName, null, DateTime.Now.AddSeconds(45), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Default,null);
            //datatable1 = (DataTable)Cache["FTEUsersList"];                
            InitializeGrid();
            GridviewDatabind(dtUserName);        
        }            
        catch(Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }

    // gridviewdatabind function
    public void GridviewDatabind(DataTable dtUserName)
    {
        int icount = 0;
        const int ADS_UF_ACCOUNTDISABLE = 0x00000002;
        try
        {
            DirectoryEntry oDirectory = new DirectoryEntry();
            oDirectory.Path = System.Configuration.ConfigurationManager.AppSettings["DirectoryPath"];
            DirectorySearcher oADSearcher = new DirectorySearcher(oDirectory);
            oDirectory.AuthenticationType = AuthenticationTypes.Secure;

            oADSearcher.SearchRoot = oDirectory;

            for (icount = 0; icount &lt; dtUserName.Rows.Count; icount++)
            {
                oADSearcher.Filter = "(SAMAccountName=" + dtUserName.Rows[icount][0].ToString() + ")";
                SearchResult results = oADSearcher.FindOne();
                if (oADSearcher.FindOne() != null)
                {
                    int flags = Convert.ToInt32(results.Properties["userAccountControl"][0].ToString());
                    if (Convert.ToBoolean(flags &amp; ADS_UF_ACCOUNTDISABLE))
                    {
                        if (Convert.ToBoolean(dtUserName.Rows[icount][1].ToString()) == true)
                        {
                            DataRow row1 = dtTempTable.NewRow();
                            row1["UserName"] = dtUserName.Rows[icount][0].ToString();
                            row1["Status"] = "User is Active in FTE and Disabled in AD";
                            dtTempTable.Rows.Add(row1);
                        }
                    }
                    else
                    {
                        if (Convert.ToBoolean(dtUserName.Rows[icount][1].ToString()) == false)
                        {
                            dtTempTable.Rows.Add(dtUserName.Rows[icount][0].ToString(), "User is InActive in FTE and Enabled in AD");
                        }
                    }
                }
                else
                {
                    dtTempTable.Rows.Add(dtUserName.Rows[icount][0].ToString(), "User Exists in FTE and not in AD");
                }
            }
            gridSyncResults.DataSource = dtTempTable;
            gridSyncResults.DataBind();
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
</code></pre>

<p>on page index change iam doing</p>

<pre><code>protected void gridSyncResults_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    DataTable dtFTEUser=new DataTable();
    gridSyncResults.PageIndex = e.NewPageIndex;
    dtFTEUser = (DataTable)Cache["FTEUsers"];
    GridviewDatabind(dtFTEUser);
}
</code></pre>

<p>data is showing with all records in page nos but when i hit 2ndpage same data of 1st page is daiplyed i cant navigate to 2nd page, even after selecting5 page same data is displaying of 1st page</p>

<p>your help will be appreciated.</p>
