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