protected void Page_Load(object sender, EventArgs e) { _pager = new PagerHelper(GetCurrentPage(), GetPageSize(), LinkRepository.GetCount()); Links.DataSource = LinkRepository.CreateQuery( "from Link l order by l.Category.Name, l.Name" ).SetFirstResult(_pager.CurrentRow).SetMaxResults(_pager.PageSize).List(); Links.DataBind(); }
protected void WriteLinks(HtmlTextWriter output) { Category currentCategory = null; IList <Link> links = LinkRepository.CreateQuery( "from Link l order by l.Category.Name, l.Name" ).List <Link>(); output.RenderBeginTag(HtmlTextWriterTag.Dl); foreach (Link link in links) { if (link.Category != currentCategory) { if (currentCategory != null) { // Render the end of the DD and UL tags. output.RenderEndTag(); output.RenderEndTag(); } currentCategory = link.Category; output.RenderBeginTag(HtmlTextWriterTag.Dt); output.WriteEncodedText(currentCategory.Name); output.RenderEndTag(); output.RenderBeginTag(HtmlTextWriterTag.Dd); output.RenderBeginTag(HtmlTextWriterTag.Ul); } output.RenderBeginTag(HtmlTextWriterTag.Li); output.AddAttribute(HtmlTextWriterAttribute.Href, link.Url); output.AddAttribute(HtmlTextWriterAttribute.Target, "_blank"); output.AddAttribute(HtmlTextWriterAttribute.Title, string.Format("Open {0} in a new window", link.Url)); output.RenderBeginTag(HtmlTextWriterTag.A); output.WriteEncodedText(link.Name); output.RenderEndTag(); output.RenderEndTag(); } // Render the end of the DD and UL tags. output.RenderEndTag(); output.RenderEndTag(); // Render the end of the DL list. output.RenderEndTag(); }