I have this piece of code and I can't figure out why Extended is never true. When a user choose extended on the dropdown list something happens. However when the page refreshes updates, the dropdown goes back to the default value of CURRENT. Is there a way to make sure it stays on EXTENDED even after a page refresh or if I come back from a different page? Here is the query string after doing a certain task on the page:
/Queue/Queue.aspx?DrawingRequestId=376333&doQuerySearch=true&start=&end=&Ind=&Model=&status=Open&manager=&source=&assignee=&title=&features=&parts=&pas=&customer=&number=&project=&startIndex=1&endIndex=10&pageSize=10&total=202&date=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");
}
}
}
}
load queue takes the currently selected drpDateView.Item value and fills the page with the relevant data.
private void LoadQueue(string dateFilter)
{
LoadQueue(dateFilter, StartIndex, EndIndex, MaxResults);
}
I had the for loop breaking in the wrong spot. This seemed to fix my issue. I also had EXTENDED getting adding to the list more than necessary, so I removed the else statement which adds it if it isn't a postback.
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();
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");
}
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.