protected void Page_Load(object sender, EventArgs e)
 {
     ddlType.DataSource     = MeetingClass.getMeetingTypes();
     ddlType.DataTextField  = "Type";
     ddlType.DataValueField = "CatID";
     ddlType.DataBind();
     if (Session["cal"] != null)
     {
         if (Convert.ToBoolean(Session["cal"]))
         {
             cbCal.Checked = true;
         }
     }
     if (Session["meet"] != null)
     {
         if (Convert.ToBoolean(Session["meet"]))
         {
             cbMeet.Checked = true;
         }
     }
     if (Session["app"] != null)
     {
         if (Convert.ToBoolean(Session["app"]))
         {
             cbApp.Checked = true;
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request["id"] != null)
                {
                    // get info
                    try
                    {
                        string username = User.Identity.Name;
                        int    id       = Convert.ToInt32(Request["id"]);
                        if (MeetingClass.CParticipant.isParticipant(id, username))
                        {
                            var evn = MeetingClass.MeetingInfo.GetMeeting(id);
                            tbID.Value    = id.ToString();
                            tbtitle.Value = evn.Title;
                            tbSDate.Value = evn.Start.ToShortDateString();
                            tbEDate.Value = evn.End.ToShortDateString();
                            tbSTime.Value = evn.Start.ToShortTimeString();
                            tbETime.Value = evn.End.ToShortTimeString();
                            tbDesc.Value  = evn.Desc;
                            ClientScriptManager script = Page.ClientScript;

                            // check if the user is allowed

                            script.RegisterClientScriptBlock(this.GetType(), "test", "<script>setMeetingID(" + id + "); </script>");

                            // fill locations
                            var locations = MeetingClass.CResource.GetAvailableLocations(evn.Start, evn.End);
                            if (locations.Count() == 0)
                            {
                                lbLocation.Items.Add("No Location available for this meeting's time and date");
                            }
                            else
                            {
                                lbLocation.DataSource     = locations;
                                lbLocation.DataValueField = "LocationID";
                                lbLocation.DataTextField  = "LocationName";
                                lbLocation.DataBind();
                            }

                            // get discussions
                            var    result    = DiscussionClass.MeetingDiscussion.GetListMeetingDiscussions(id);
                            string disScript = @"<p><a href=""#"" title=""{0}"" onclick=""ShowDiscussion(this); return false;"">{1}</a></p><p class=""pull-right""><b> Created by:</b> {2}<b> On:</b> {3}<b> Replys: </b>{4}</p><hr />";
                            foreach (var t in result)
                            {
                                DiscussionList.InnerHtml += string.Format(disScript, t.ID, t.Title, t.UserName, t.Date.ToString("MM/dd/yyyy | hh:mm:ss"), t.Replies.ToString());
                            }

                            // Privacy fro Agenda
                            if (AgendaClass.AgendaPrivacyClass.CheckRole(username, id, MeetingRoles.Creator))
                            {
                                divAddAgendaTask.Visible = true;
                            }
                            else
                            {
                                divAddAgendaTask.Visible = false;
                            }
                        }
                        else
                        {
                            Response.Redirect("~/Error.aspx");
                        }
                    }
                    catch
                    {
                    }

                    // get participant
                    //var parti = MeetingClass.Participant.getMeetingParticipant(id);
                    //int index = 1;
                    //foreach (var r in parti)
                    //{
                    //    HtmlTableRow row = new HtmlTableRow();
                    //    HtmlTableCell num = new HtmlTableCell();
                    //    num.InnerText = index.ToString();
                    //    row.Cells.Add(num);
                    //    HtmlTableCell user = new HtmlTableCell();
                    //    user.InnerText = r.UserName;
                    //    row.Cells.Add(user);
                    //    HtmlTableCell role = new HtmlTableCell();
                    //    role.InnerText = r.Role;
                    //    row.Cells.Add(role);
                    //    HtmlTableCell res = new HtmlTableCell();
                    //    res.InnerText = r.Response;
                    //    row.Cells.Add(res);
                    //    HtmlTableCell note = new HtmlTableCell();
                    //    note.InnerText = r.Note;
                    //    row.Cells.Add(note);
                    //    HtmlTableCell close = new HtmlTableCell();
                    //    close.InnerHtml = "<a href='#' onclick='return Delete(this)'><span class='icon-x'></span></a>";
                    //    row.Cells.Add(close);

                    //    // add row to table
                    //    parTable.Rows.Add(row);
                    //    index++;
                    //    btnInvite.Visible = true;
                    //}
                }
                else
                {
                    if (!Roles.ChkAdmin(User.Identity.Name))
                    {
                        Response.Redirect("~/Error.aspx");
                    }
                }
                // fill resources
                SetResources();
                // fill MTypes
                ddlMType.DataSource     = MeetingClass.getMeetingTypes();
                ddlMType.DataTextField  = "Type";
                ddlMType.DataValueField = "CatID";
                ddlMType.DataBind();
                // get all participants
                string[] users = ldap.getListOfUsersTemp().OrderBy(a => a).ToArray();
                lbPart.DataSource = users;
                lbPart.DataBind();
                //for (int o = 0; o < users.Count(); o++ )
                //{

                //    //string str = @"<label class=""checkbox""><input type=""checkbox"" id=""chk"" runat=""server"">";
                //    //str += @"<span class=""metro-checkbox"">" + users[o] + "</span></label>";
                //    //if (o < users.Count()/2)
                //    //{
                //    //    divAttendees1.InnerHtml += str;
                //    //}
                //    //else
                //    //{
                //    //    divAttendees2.InnerHtml += str;
                //    //}
                //}
            }
        }