Пример #1
0
        protected void perfumeList_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            //find the nested listview
            System.Web.UI.WebControls.ListView listView = e.Item.FindControl("ListView1") as System.Web.UI.WebControls.ListView;
            // find the name of current marca
            Label label = e.Item.FindControl("Label1") as Label;

            //get all the perfumes with the current marca
            //here I use linq , you could use other ways only if you could get the perfumes having the current marca
            listView.DataSource = table.AsEnumerable().Where(row => row["marca"] as string == label.Text).Select(row => new { name = row["name"], price = row["price"] }).ToList();
            listView.DataBind();
        }
        private void CarregarMensagens(TipoMensagemEnum tipoMensagem, ListView listView)
        {
            var mensagensSucesso = SessionHelper.ListMensagens.Where(m => m.TipoMensagem == tipoMensagem);

            if (mensagensSucesso.Any())
            {
                listView.Parent.Visible = true;

                listView.DataSource = mensagensSucesso;
                listView.DataBind();
            }
            else
                listView.Parent.Visible = false;
        }
Пример #3
0
        /// <summary>
        /// Sets datasource of listview.
        /// </summary>
        /// <remarks>
        /// Loads tags form Content Repository and adds the following properties of them to a datatable:
        /// DisplayName, Created By, Creation Date, Modification Date, Reference Count, Path, Is Blacklisted an Node ID.
        /// Sets this datatable as datasource to the listview.
        /// </remarks>
        private void SetDataSource()
        {
            var refCounts = TagManager.GetTagOccurrencies();

            var exprList = new ExpressionList(ChainOperator.And);

            exprList.Add(new TypeExpression(ActiveSchema.NodeTypes["Tag"], true));
            exprList.Add(new StringExpression(StringAttribute.Path, StringOperator.StartsWith, TagPath));

            var nq = new NodeQuery(exprList);

            var result = nq.Execute();

            var dt = new DataTable();
            _tagsInRepository = new List<string>();

            dt.Columns.AddRange(new[] { 
                                        new DataColumn("DisplayName", typeof(String)),
                                        new DataColumn("CreatedBy", typeof(String)), 
                                        new DataColumn("CreationDate", typeof(DateTime)), 
                                        new DataColumn("ModificationDate", typeof(DateTime)), 
                                        new DataColumn("RefCount", typeof(Int32)), 
                                        new DataColumn("Path", typeof(String)),
                                        new DataColumn("IsBlackListed", typeof(String)),
                                        new DataColumn("ID", typeof(Int32))
                                });

            foreach (var item in result.Nodes.ToList())
            {
                dt.Rows.Add(new object[]
                                {
                                    item.DisplayName,
                                    item.CreatedBy,
                                    item.CreationDate,
                                    item.ModificationDate,
                                    refCounts.ContainsKey(item.DisplayName) ? refCounts[item.DisplayName] : 0,
                                    item.Path, GetIsBlackListed(item.Id),
                                    Convert.ToInt32(item.Id)
                                });
                if (GetIsBlackListed(item.Id) == "No")
                    _tagsInRepository.Add(item.DisplayName);
            }

            _allTags = TagManager.GetAllTags(null, SearchPaths);

            dt.DefaultView.Sort = !String.IsNullOrEmpty(Request.QueryString["OrderBy"]) ? String.Concat(Request.QueryString["OrderBy"], " " + Request.QueryString["Direction"]) : "DisplayName ASC";

            _lv = FindControl("LVTags") as ListView;
            if (_lv != null)
            {
                _lv.DataSource = dt.DefaultView;
                _lv.DataBind();
            }
        }