我有这段代码,但我无法弄清楚为什么Extended永远不会成真。当用户在下拉列表中选择扩展时会发生一些事情。但是,当页面刷新更新时,下拉列表将返回默认值CURRENT。有没有办法确保它在页面刷新后或者从不同的页面返回时仍然保持EXTENDED状态?这是在页面上执行某项任务后的查询字符串:
/Queue/Queue.aspx?DrawingRequestId=376333&doQuerySearch=true&start=&end=&Ind=&Model=&status=Open&manager=&source=&assignee=&标题=安培;特征=安培;份数=安培; PAS =安培;顾客=安培;数=安培;项目=安培;的startIndex = 1&安培; endIndex的= 10安培;的pageSize = 10安培;总数= 202&安培;日期= EXTENDED&安培; qsEnd =
public bool Extended
{
get
{
if (Request.QueryString["&date"] == "EXTENDED")
{
return true;
}
return false;
}
}
protected void Page_Load(object sender, EventArgs e)
{
// Tell this page to use the wide setting on the master page
Master.UseWideSetting = true;
//Check to see if the user has permission
CheckPageForPermission("Queue");
base.SetActiveMenuItem(3);
ucPager.PageChange += new EDDC.Controls.Pager.EmptyEventHandler(ucPager_PageChange);
GenerateSearchQueryString();
List<CAT.EDDC.Data.UserRole> roles = Common.GetCurrentUserRoles();
foreach (CAT.EDDC.Data.UserRole r in roles)
{
if (r.AddOnRole == "PUB")
{
bool exists = false;
foreach (ListItem item in drpDateView.Items)
{
if (item.Value == "Extended")
{
exists = true;
}
break;
if (!exists)
{
// Add the item if permissions are correct
drpDateView.Items.Insert(1, new ListItem("Extended", "EXTENDED"));
}
}
if (Extended)
{
LoadQueue("EXTENDED");
}
else
{
LoadQueue("CURRENT");
}
}
}
if (!Page.IsPostBack)
{
if (AutoSearch)
{
if (DrawingId != null)
{
AutoSearchPopulate();
}
/*------------------------------------------------------
* Bug 3209 Drawing Number Included
*
* Resolution - Removed the Call to Populate the search.
* Also removed the Property for Drawing Number
* -----------------------------------------------------*/
qsSearch.Collapsed = false;
lblUsername.Text = Common.GetCurrentUserRec().ScreenName;
popupWindow.UpdatePanelToRefresh = upnlRequest.ClientID;
ResetPager();
//List<CAT.EDDC.Data.UserRole> roles = Common.GetCurrentUserRoles();
drpDateView.Items.Insert(1, new ListItem("Extended", "Extended"));
drpDateView.SelectedValue = "EXTENDED";
LoadQueue("Extended");
}
else if (RefreshSearch)
{
LoadSearchParameters();
LoadQueueFromQueryString();
}
else
{
lblUsername.Text = Common.GetCurrentUserRec().ScreenName;
popupWindow.UpdatePanelToRefresh = upnlRequest.ClientID;
ResetPager();
//List<CAT.EDDC.Data.UserRole> roles = Common.GetCurrentUserRoles();
foreach (CAT.EDDC.Data.UserRole d in roles)
{
if (d.AddOnRole == "PUB")
{
drpDateView.Items.Insert(1, new ListItem("Extended", "EXTENDED"));
}
}
if (Extended)
{
LoadQueue("EXTENDED");
}
else
{
LoadQueue("CURRENT");
}
}
}
}
加载队列获取当前选定的drpDateView.Item值并使用相关数据填充页面。
private void LoadQueue(string dateFilter)
{
LoadQueue(dateFilter, StartIndex, EndIndex, MaxResults);
}
答案 0 :(得分:0)
我让for循环在错误的地方打破了。这似乎解决了我的问题。我也有EXTENDED在列表中添加了超过必要的内容,所以如果不是回发,我删除了添加它的else语句。
protected void Page_Load(object sender,EventArgs e) { //告诉此页面使用母版页上的宽屏设置 Master.UseWideSetting = true;
//Check to see if the user has permission
CheckPageForPermission("Queue");
base.SetActiveMenuItem(3);
ucPager.PageChange += new EDDC.Controls.Pager.EmptyEventHandler(ucPager_PageChange);
GenerateSearchQueryString();
List<CAT.EDDC.Data.UserRole> roles = Common.GetCurrentUserRoles();
foreach (CAT.EDDC.Data.UserRole r in roles)
{
if (r.AddOnRole == "PUB")
{
bool exists = false;
foreach (ListItem item in drpDateView.Items)
{
if (item.Value == "Extended")
{
exists = true;
break;
}
}
if (!exists)
{
// Add the item if permissions are correct
drpDateView.Items.Insert(1, new ListItem("Extended", "EXTENDED"));
}
if (Extended)
{
LoadQueue("EXTENDED");
}
else
{
LoadQueue("CURRENT");
}
}
}
if (!Page.IsPostBack)
{
if (AutoSearch)
{
if (DrawingId != null)
{
AutoSearchPopulate();
}
/*------------------------------------------------------
* Bug 3209 Drawing Number Included
*
* Resolution - Removed the Call to Populate the search.
* Also removed the Property for Drawing Number
* -----------------------------------------------------*/
qsSearch.Collapsed = false;
lblUsername.Text = Common.GetCurrentUserRec().ScreenName;
popupWindow.UpdatePanelToRefresh = upnlRequest.ClientID;
ResetPager();
//List<CAT.EDDC.Data.UserRole> roles = Common.GetCurrentUserRoles();
if (!drpDateView.Items.Contains(new ListItem("Extended", "Extended")))
drpDateView.Items.Insert(1, new ListItem("Extended", "Extended"));
drpDateView.SelectedValue = "EXTENDED";
LoadQueue("Extended");
}
else if (RefreshSearch)
{
LoadSearchParameters();
LoadQueueFromQueryString();
}
else
{
lblUsername.Text = Common.GetCurrentUserRec().ScreenName;
popupWindow.UpdatePanelToRefresh = upnlRequest.ClientID;
ResetPager();
//List<CAT.EDDC.Data.UserRole> roles = Common.GetCurrentUserRoles();
if (Extended)
{
LoadQueue("EXTENDED");
}
else
{
LoadQueue("CURRENT");
}
}
}
}