我有两个gridView:grvHeadline
和gdvNotification
,gdvNotification
是按照grvHeadline的选定项加载数据。
页面加载时:gdvNotification
的数据按grvHeadline
的第一项加载。
我的问题是:
页面加载是第一个:如果gdvNotification
有分页(1,2,3,...),当我点击gdvNotification
中的分页时,它就不会运行。页面重新加载,但页面索引为0
。
当我在grvHeadline
中选择其他项目并重新选择第一项时,然后点击gdvNotification
中的分页,运行,页面索引已更改。
我正在调试:第一次加载页面时:我点击gdvNotification
中的页面索引,然后使用pageload()
调用IsPostBack=True
,但不调用事件{{1} } gdvNotification_PageIndexChanging
。
这是我的代码:
gdvNotification
并且
protected void gdvNotification_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
logger.Debug("Gridview Headline page index changing .");
gdvNotification.PageIndex = e.NewPageIndex;
HeadlineSelected(hdfNotificationIdSelected.Value, e.NewPageIndex);
//gdvNotification.DataBind();
lbPageIndex.Text = (e.NewPageIndex + 1).ToString(CultureInfo.InvariantCulture);
}
更新视图中的代码* .aspx。
private void HeadlineSelected(string notificationIdSelected, int index)
{
logger.Debug("Head line selected");
GetDataFromSessionAndCache();
IList<InformationEntity> infoNotificationList = new List<InformationEntity>();
if (string.IsNullOrEmpty(notificationIdSelected))
{
//Clear
IList<InformationEntity> data = new List<InformationEntity>()
{
new InformationEntity()
{
AuthorName = string.Empty,
Contents = string.Empty,
BulletinDateFrom = null,
BulletinDateTo = null,
Id = string.Empty,
Subject = string.Empty,
}
};
gdvNotification.DataSource = data;
gdvNotification.DataBind();
pnPageIndex.Visible = false;
btnEditNotification.Enabled = false;
}
else
{
infoNotificationList = MasterDataHelper.GetInformationByHighOrderId(notificationIdSelected);
logger.Debug("Notification list not null");
if (infoNotificationList != null)
{
if (infoNotificationList.Count == 0)
{
pnPageIndex.Visible = false;
hdfNotificationId.Value = string.Empty;
btnEditNotification.Enabled = false;
}
else
{
if (infoNotificationList.Count == 1)
{
fakepanel.Visible = true;
}
else
{
fakepanel.Visible = false;
}
if (base.IsPermission(PERMISSION_INFORMATION_FOLLOWUP))
{
btnEditNotification.Enabled = true;
}
pnPageIndex.Visible = true;
gdvNotification.PageIndex = index;
hdfNotificationId.Value = infoNotificationList[index].Id;
gdvNotification.DataSource = infoNotificationList;
gdvNotification.DataBind();
}
logger.Debug("Set value for label total page");
lblTotalPage.Text = gdvNotification.PageCount.ToString(CultureInfo.InvariantCulture);
lbPageIndex.Text = gdvNotification.PageCount == 0
? gdvNotification.PageCount.ToString(CultureInfo.InvariantCulture)
: (gdvNotification.PageIndex + 1).ToString(CultureInfo.InvariantCulture);
lbTotal.Text = infoNotificationList.Count().ToString(CultureInfo.InvariantCulture);
}
}
}
有人可以告诉我发生了什么吗?
(p / s:我正在努力学习英语,如果你不明白,请告诉我。)