protected void Page_Load(object sender, EventArgs e) { int cid = 1; string q = Request.QueryString["cid"]; try { if (q == null) { cid = 1; } else { cid = Convert.ToInt32(q); } } catch (Exception) { cid = 1; } var cats = HelpTopicService.GetHelpCat(); CatRepeater.DataSource = cats; var cat = HelpTopicService.GetHelpCat(cid); if (cat != null) { CatName = cat.Name; var topics = HelpTopicService.GetHelpTopicList(cid); TopicRepeater.DataSource = topics; } DataBind(); }
protected void Page_Load(object sender, EventArgs e) { try { string q = Request.QueryString["id"]; int id = Convert.ToInt32(q); if (id == 0) { throw new Exception(); } var topic = HelpTopicService.GetHelpTopic(id); if (topic == null) { throw new Exception(); } var cats = HelpTopicService.GetHelpCat(); CatRepeater.DataSource = cats; var cat = cats.FirstOrDefault(c => c.Id == topic.Cat); if (cat == null) { throw new Exception(); } TopicTitle = topic.Title; TopicContent = topic.Content; DataBind(); } catch (Exception) { Response.Redirect("HelpList.aspx"); } }