我使用datagridview显示数据,它有3000条记录。
按钮中的单击iam调用
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 < 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 & 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;
}
}
页面索引更改我正在做
protected void gridSyncResults_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
DataTable dtFTEUser=new DataTable();
gridSyncResults.PageIndex = e.NewPageIndex;
dtFTEUser = (DataTable)Cache["FTEUsers"];
GridviewDatabind(dtFTEUser);
}
数据显示在页面nos中的所有记录但当我点击第2页相同的第1页数据时,我无法导航到第2页,即使在选择5页相同的数据显示第1页
您的帮助将不胜感激。