protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Set style top link where they stand HtmlAnchor a = (HtmlAnchor)Master.FindControl("relax"); if (a != null) { a.Attributes.Add("class", "topMenuDVLinkActive"); } SetSitemap(); try { using (DataClassesDataContext data = new DataClassesDataContext()) { int ItemCount = int.Parse(data.GetRelaxNewsItemCount().ToList()[0].ItemCount); AspNetPager1.RecordCount = ItemCount; GetTrainings(); } } catch (Exception ex) { // error message here } } }