我有一个有分页的网格视图。在将数据绑定到网格视图后,我将根据下拉列表的选择过滤网格。这导致2页的结果。但是当我点击第2页时,网格刷新了原始结果。这是我的代码:
DataTable dtSyncQueueTransfer = syncStatusBizManager.GetSyncTransferResult(syncRequestId, serverIds, statusIds, txtFileName.Value);
ViewState["SyncResults"] = dtSyncQueueTransfer;
gvSyncQueueList.DataSource = dtSyncQueueTransfer;
gvSyncQueueList.DataBind();
protected void ddlProjectId_SelectedIndexChanged(object sender, EventArgs e)
{
DataTable dtSyncResults = (DataTable)ViewState["SyncResults"];
//To display all the sync results when the dropdown selected value is All.
if (ddlProjectId.SelectedValue.ToString().Equals("All"))
{
gvSyncQueueList.DataSource = dtSyncResults;
gvSyncQueueList.DataBind();
}
//To display the sync results when the user selects a projectId from the drop down.
else
{
DataView viewResults = new DataView(dtSyncResults);
//Filtering sync results based on projectid.
viewResults.RowFilter = "ProjectId =" + Convert.ToInt32(ddlProjectId.SelectedValue);
gvSyncQueueList.DataSource = viewResults;
gvSyncQueueList.DataBind();
}
}
protected void gvSyncQueueList_OnPageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvSyncQueueList.PageIndex = e.NewPageIndex;
gvSyncQueueList.DataSource = (DataTable)ViewState["SyncResults"];
gvSyncQueueList.DataBind();
string activetab = GetActiveTab();
ShowTabs(activetab);
}
有人可以为此提供帮助吗?
答案 0 :(得分:0)
这是我的问题的解决方案。我们需要在分页时重新过滤结果。 在更改网格页面时,我们需要更改代码如下:
QOS_CLASS_DEFAULT