private PageReference GetSelectedPageId() { PageReference pageRef; //If there is a query string attribute called selectednewspage, use that. if (PageReference.TryParse(Request.QueryString["selectednewspage"], out pageRef)) { return(pageRef); } //Use the first item in the list as a default value. foreach (PageData page in NewsListing) { return(page.PageLink); } return(CurrentPage.PageLink); }