示例#1
0
    protected void initJobs(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            var           jobday   = e.Item.FindControl("day") as Label;
            var           personal = e.Item.FindControl("personal") as Label;
            Repeater      repeater = e.Item.FindControl("jobs") as Repeater;
            JobList       jobList  = e.Item.DataItem as JobList;
            List <Person> persons  = new List <Person>();

            if (jobList != null && repeater != null && jobday != null)
            {
                if (personal != null)
                {
                    persons = SiteUtilities.GetAvaliablePersonal(jobList.Date);
                    for (int i = 0; i < persons.Count; i++)
                    {
                        if (persons[i].Active)
                        {
                            string name = persons[i].Firstname + " " + persons[i].Lastname.Substring(0, 1) + " ";
                            personal.Text += name;
                        }
                    }
                }
                jobday.Text         = jobList.Date.ToString("dddd", new System.Globalization.CultureInfo("sv-SE")) + " " + jobList.Date.ToString("m");
                repeater.DataSource = jobList.Jobs;
                repeater.DataBind();
            }
        }
    }