Objectdatasource

Kun je vullen met data via een method die een dataview teruggeeft.
In de properties van de datasource selectparameters aangegeven, deze moet dan als parameters gedefinieerd worden in je method.

Werkwijze: je leest de data in een generic list in en filtert ( met list.contain ) deze list op deze parameters, indien dit klopt dan voeg je dat record van de list toe aan de dataview.

public DataView HaalMedewerkers(string name, string title, string phone, string local, string email, string initials)
        {
            DataView view = new DataView(new DataTable("empty"));
            DataTable table = new DataTable("table");
            table.Columns.Add("Name");
            table.Columns.Add("Title");
            table.Columns.Add("Location");
            table.Columns.Add("Phone");
            table.Columns.Add("Cell");
            table.Columns.Add("Email");
            table.Columns.Add("Path");
            table.Columns.Add("Image");

            if ((((name != "") || (title != "")) || ((phone != "") || (local != ""))) || ((email != "") || (initials != "")))
            {
                Item item = Sitecore.Context.Database.Items["/sitecore/content/intranet/home/userinfo"];
                Sitecore.Collections.ChildList children = item.Children;
                for (int i = 0; i < children.Count; i++)
                {
                    Item contentItem = Sitecore.Intranet.ApplicationCode.Utils.IntranetLanguageResolver.GetContentItem(children[i]);
                    if ((((contentItem != null) && contentItem.Key.Contains(initials.ToLower())) && (contentItem["name"].ToLower().Contains(name.ToLower()) && contentItem["title"].ToLower().Contains(title.ToLower()))) && ((contentItem["phone"].ToLower().Contains(phone.ToLower()) && contentItem["local"].ToLower().Contains(local.ToLower())) && contentItem["email"].ToLower().Contains(email.ToLower())))
                    {
                        DataRow rij = table.NewRow();

                        rij["Name"] = children[i]["name"];
                        rij["Title"] = children[i]["title"];
                        if (children[i]["location"] != "")
                        {
                            Item tmp = Sitecore.Context.Database.Items[children[i]["location"]];
                            if (tmp != null)
                            {
                                rij["Location"] = tmp["title"];
                            }
                        }
                        rij["Phone"] = children[i]["phone"];
                        rij["Cell"] = children[i]["cell"];
                        rij["Email"] = children[i]["email"];
                        rij["Path"] = children[i]["path"];
                        rij["Image"] = children[i]["image"];
                        table.Rows.Add(rij);
                    }
                }
            }
            view.Table = table;
            return view;
        }

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!