PageRenderTime 50ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/Src/uSiteBuilder.Admin/NestedRepeater.ascx.cs

https://bitbucket.org/gfyans/kelvindigital.usitebuilder.package
C# | 46 lines | 37 code | 8 blank | 1 comment | 5 complexity | 29a6ccbd28f9bc1ec5b7bde4f3ffb25b MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using Vega.USiteBuilder;
  8. namespace kelvinDigital.USiteBuilderAdmin
  9. {
  10. public partial class usercontrols_NestedRepeater : System.Web.UI.UserControl
  11. {
  12. public List<ContentComparison> Data { get; set; }
  13. public string ParentAlias { get; set; }
  14. protected override void OnDataBinding(EventArgs e)
  15. {
  16. base.OnDataBinding(e);
  17. rptList.DataSource = Data.Where(d => d.ParentAlias == ParentAlias);
  18. rptList.DataBind();
  19. }
  20. protected void rptList_DataBound(object sender, RepeaterItemEventArgs e)
  21. {
  22. if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
  23. {
  24. rptList.Visible = true;
  25. //var childRepeater = (e.Item.FindControl("rptChildren") as usercontrols_NestedRepeater);
  26. var childPlaceholder = (e.Item.FindControl("plcChildren") as PlaceHolder);
  27. ContentComparison contentComparison = ((e.Item.DataItem) as ContentComparison);
  28. string parent = contentComparison.ParentAlias;
  29. usercontrols_NestedRepeater childRepeater =
  30. (usercontrols_NestedRepeater) LoadControl("NestedRepeater.ascx");
  31. childPlaceholder.Controls.Add(childRepeater);
  32. childRepeater.Data = Data;
  33. childRepeater.ParentAlias = contentComparison.Alias;
  34. childRepeater.DataBind();
  35. }
  36. }
  37. }
  38. }