Skip to content

Latest commit

 

History

History
41 lines (32 loc) · 1.16 KB

items-list.md

File metadata and controls

41 lines (32 loc) · 1.16 KB

#List of items

Learn how to use and extend items.

Example using asp:Repeater

  protected void Page_Load(object sender, EventArgs e)
  {
      loadList();
  }

  //repeater ItemDataBound
  protected void Rep1_ItemDataBound(object sender, RepeaterItemEventArgs e)
  {
      if (e.Item.ItemType == ListItemType.Header)
          return;

      var item = (Item)e.Item.DataItem;

      var LitTitle = (Literal)e.Item.FindControl("LitTitle");
      LitTitle.Text = item.Title;

      var LitImg = (Literal)e.Item.FindControl("LitImg");
      LitImg.Text = "<img src='" + item.DefaultImage.FileUrl + "' width='50' />";

      var LitPermissions = (Literal)e.Item.FindControl("LitPermissions");
      LitPermissions.Text = item.ReadAccessType.ToString();
  }

  private void loadList()
  {
      //first parameter means to check userContext
      var man = new PigeonCms.ItemsManager<Item, ItemsFilter>(/*checkUserContext*/true, /*writeMode*/false);
      var filter = new PigeonCms.ItemsFilter();
      filter.CategoryId = Acme.Settings.SampleCatId;
      var list = man.GetByFilter(filter, "");

      Rep1.DataSource = list;
      Rep1.DataBind();
  }