Repeater controls

<asp:Repeater ID="dayRepeater" runat="server"  OnItemDataBound="dayRepeaterItemDataBound">
                <HeaderTemplate>
                <%--PKM added id for the tr--%>
                    <table class="main" cellspacing="0" cellpadding="0" align="center">
                        <tr id="thTopPanel" runat="server">
                            <th   class="empty" style="height: 29px;">
                                &nbsp;
                            </th>
                            <th id="dateLtlContainer" runat="server" style="height: 29px; width: 560px">
                                <asp:Literal ID="dateLtl" runat="server" />
                            </th>
                        </tr>
                       
                </HeaderTemplate>
                <ItemTemplate>
                    <tr id="apptRow" runat="server">
                     <%--PKM added id for the th--%>
                        <th class="row" id="thLeftPanel" runat="server" width="10px">
                            <asp:Literal ID="timeLtl" runat="server" />
                        </th>
                        <td>
                            <div style="text-align: right;">
                                <a id="cal_dayadd_event" href="events.aspx" runat="server">
                                    <img alt="" border="0" src="images/icon-add-big.gif" />
                                </a>
                            </div>
                            <asp:Repeater ID="dayChildRep" runat="server" OnItemDataBound="dayChildRep_ItemDataBound">
                                <ItemTemplate>
                                    <div style="text-align: left;">
                                        <asp:Panel ID="target_panel" runat="server">
                                            <input type="hidden" id="patMrnh" runat="server" />
                                            <input type="hidden" id="patLastNmh" runat="server" />
                                            <input type="hidden" id="patFirstNmh" runat="server" />
                                            <input type="hidden" id="apptDateh" runat="server" />
                                            <input type="hidden" id="apptTimeh" runat="server" />
                                            <input type="hidden" id="apptParticipantsh" runat="server" />
                                            <input type="hidden" id="apptTitleh" runat="server" />
                                            <input type="hidden" id="apptTypeh" runat="server" />
                                            <input type="hidden" id="apptDesch" runat="server" />
                                        </asp:Panel>
                                    </div>
                                </ItemTemplate>
                            </asp:Repeater>
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>

  protected void dayRepeaterItemCommand(Object sender, RepeaterCommandEventArgs e)
        {

        }



  protected void dayRepeaterItemDataBound(Object Sender, RepeaterItemEventArgs e)
        {
            string times = "";

         
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {

                //PKM
                HtmlTableCell thTopPanel = (HtmlTableCell)e.Item.FindControl("thLeftPanel");
                thTopPanel.Style.Add(HtmlTextWriterStyle.BackgroundColor, "Green");
                string str1 = "Red";
                //PKM


                Literal timeCol = (Literal)e.Item.FindControl("timeLtl");
                if (DataBinder.Eval(e.Item.DataItem, "times").ToString() != "")
                {
                    if (DataBinder.Eval(e.Item.DataItem, "times").ToString() != "All Day")
                        timeCol.Text = Convert.ToDateTime(DataBinder.Eval(e.Item.DataItem, "times")).ToShortTimeString();
                    else
                        timeCol.Text = DataBinder.Eval(e.Item.DataItem, "times").ToString();
                }
                times = timeCol.Text;
                //PKM
                timeCol.Text = "<font color='" + str1 + "'>" + times + "</font>";
                //PKM
                HtmlAnchor cal_dayadd_event = (HtmlAnchor)e.Item.FindControl("cal_dayadd_event");
                if (cal_dayadd_event != null)
                    cal_dayadd_event.HRef = "events.aspx?day_date=" + hdnDate.Value + "&day_time=" + times;

                Repeater dayChildRep = (Repeater)e.Item.FindControl("dayChildRep");
                DataSet local_ds = GetApptsByTime(times);
                if (local_ds.Tables.Count > 0)
                {
                    dayChildRep.DataSource = GetApptsByTime(times);
                    dayChildRep.DataBind();
                }
            }

            if (e.Item.ItemType == ListItemType.Header)
            {
                //PKM
                HtmlTableRow thTopPanel = (HtmlTableRow)e.Item.FindControl("thTopPanel");
                thTopPanel.Style.Add(HtmlTextWriterStyle.BackgroundColor, "Green");
                string str = "Red";
                //PKM
              
                Literal dateCol = (Literal)e.Item.FindControl("dateLtl");
               
                if (Request["day"] != null)
                {
                    if (Convert.ToDateTime(Request["day"]).Date != DateTime.Now.Date)
                    {
                        //PKM ADDEDTHE FONT TAG
                        dateCol.Text = "<font color='" + str + "'>" + Convert.ToDateTime(Request["day"]).DayOfWeek.ToString() + Convert.ToDateTime(Request["day"]).ToString("<br />MMMM d, yyyy") + "</font>";
                    }
                    else
                    {
                        //PKM ADDEDTHE FONT TAG
                        dateCol.Text = "<font color='" + str + "'>" + DateTime.Now.DayOfWeek.ToString() + DateTime.Now.ToString("<br />MMMM d, yyyy") + "</font>";
                        HtmlTableCell htc = (HtmlTableCell)e.Item.FindControl("dateLtlContainer");
                        htc.Attributes.Add("class", "today");
                    }
                }
                else
                {
                    //PKM ADDEDTHE FONT TAG and date format
                    string st = "d.MM.yy";
                    dateCol.Text = "<font color='" + str + "'>" + DateTime.Now.DayOfWeek.ToString() + DateTime.Now.ToString("<br />"+st) + "</font>";
                    HtmlTableCell htc = (HtmlTableCell)e.Item.FindControl("dateLtlContainer");
                    htc.Attributes.Add("class", "today");
                }
            }
        }

 protected void dayChildRep_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
        {
            string event_id = "", event_title = "", event_date = "", event_time = "", event_time_end = "",
                event_AppointmentType = "", event_PatLastName = "", event_PatFirstName = "", event_PatMrnNumber = "",
                event_Participants = "", event_is_public = "", event_desc = "", event_all_day = "", event_ParticipantsText = "";

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                event_id = DataBinder.Eval(e.Item.DataItem, "event_id").ToString();

                if (!(DataBinder.Eval(e.Item.DataItem, "event_time").ToString() == string.Empty))
                    event_time = Convert.ToDateTime(DataBinder.Eval(e.Item.DataItem, "event_time")).ToShortTimeString();

                if (!(DataBinder.Eval(e.Item.DataItem, "event_time_end").ToString() == string.Empty))
                    event_time_end = Convert.ToDateTime(DataBinder.Eval(e.Item.DataItem, "event_time_end")).ToShortTimeString();

                if (!(DataBinder.Eval(e.Item.DataItem, "event_Participants").ToString() == string.Empty))
                    event_Participants = DataBinder.Eval(e.Item.DataItem, "event_Participants").ToString();

                if (!(DataBinder.Eval(e.Item.DataItem, "event_ParticipantsText").ToString() == string.Empty))
                    event_ParticipantsText = DataBinder.Eval(e.Item.DataItem, "event_ParticipantsText").ToString();

                if (!(DataBinder.Eval(e.Item.DataItem, "event_all_day").ToString() == string.Empty))
                    event_all_day = DataBinder.Eval(e.Item.DataItem, "event_all_day").ToString();

                if (!(DataBinder.Eval(e.Item.DataItem, "event_desc").ToString() == string.Empty))
                    event_desc = DataBinder.Eval(e.Item.DataItem, "event_desc").ToString();

                if (!(DataBinder.Eval(e.Item.DataItem, "event_is_public").ToString() == string.Empty))
                    event_is_public = DataBinder.Eval(e.Item.DataItem, "event_is_public").ToString();

                if (!(DataBinder.Eval(e.Item.DataItem, "event_AppointmentType").ToString() == string.Empty))
                    event_AppointmentType = DataBinder.Eval(e.Item.DataItem, "event_AppointmentType").ToString();

                if (!(DataBinder.Eval(e.Item.DataItem, "event_title").ToString() == string.Empty))
                    event_title = DataBinder.Eval(e.Item.DataItem, "event_title").ToString();

                if (!(DataBinder.Eval(e.Item.DataItem, "event_PatLastName").ToString() == string.Empty))
                    event_PatLastName = DataBinder.Eval(e.Item.DataItem, "event_PatLastName").ToString();

                if (!(DataBinder.Eval(e.Item.DataItem, "event_PatFirstName").ToString() == string.Empty))
                    event_PatFirstName = DataBinder.Eval(e.Item.DataItem, "event_PatFirstName").ToString();

                if (!(DataBinder.Eval(e.Item.DataItem, "event_PatMrnNumber").ToString() == string.Empty))
                    event_PatMrnNumber = DataBinder.Eval(e.Item.DataItem, "event_PatMrnNumber").ToString();

                if (!(DataBinder.Eval(e.Item.DataItem, "event_date").ToString() == string.Empty))
                    event_date = DataBinder.Eval(e.Item.DataItem, "event_date").ToString();

                Panel target_panel = (Panel)e.Item.FindControl("target_panel");

                HtmlInputHidden patMrnh, patLastNmh, patFirstNmh, apptDateh, apptTimeh, apptParticipantsh, apptTitleh, apptTypeh, apptDesch;
                patMrnh = (HtmlInputHidden)e.Item.FindControl("patMrnh");
                patLastNmh = (HtmlInputHidden)e.Item.FindControl("patLastNmh");
                patFirstNmh = (HtmlInputHidden)e.Item.FindControl("patFirstNmh");
                apptDateh = (HtmlInputHidden)e.Item.FindControl("apptDateh");
                apptTimeh = (HtmlInputHidden)e.Item.FindControl("apptTimeh");
                apptParticipantsh = (HtmlInputHidden)e.Item.FindControl("apptParticipantsh");
                apptTitleh = (HtmlInputHidden)e.Item.FindControl("apptTitleh");
                apptTypeh = (HtmlInputHidden)e.Item.FindControl("apptTypeh");
                apptDesch = (HtmlInputHidden)e.Item.FindControl("apptDesch");

                if (patMrnh != null) patMrnh.Value = event_PatMrnNumber;
                if (patLastNmh != null) patLastNmh.Value = event_PatLastName;
                if (patFirstNmh != null) patFirstNmh.Value = event_PatFirstName;
                if (event_date != "")
                    if (apptDateh != null) apptDateh.Value = Convert.ToDateTime(event_date).ToString("dd-MMM-yy");
                if (event_date != "" && event_time != "" && event_time_end != "")
                { if (apptTimeh != null) apptTimeh.Value = event_time + " - " + event_time_end; }
                else
                { if (apptTimeh != null) apptTimeh.Value = "All Day"; }
                if (apptParticipantsh != null) apptParticipantsh.Value = event_Participants;
                if (apptTitleh != null) apptTitleh.Value = event_title;
                if (apptTypeh != null) apptTypeh.Value = event_AppointmentType;
                if (apptDesch != null) apptDesch.Value = event_desc;

                if (event_Participants != "")
                {
                    Panel pnlAdded = new Panel();
                    pnlAdded.ID = Guid.NewGuid().ToString();

                    Label appLabel = new Label();
                    appLabel.ID = "appLbl" + Guid.NewGuid().ToString();

                    if (event_time == "" && event_time_end == "" && event_date != "")
                        appLabel.Text = "All Day >> <br/>" + event_Participants + "<br/>";
                    else if (event_time != "" && event_time_end != "" && event_date != "")
                        appLabel.Text = event_time + " - " + event_time_end + " >> <br/>" + event_Participants + "<br/>";

                    pnlAdded.Controls.Add(appLabel);
                    target_panel.Controls.Add(pnlAdded);
                    string Red = "Blue";
                    //PKM changed Color of Panel
                    pnlAdded.BackColor = Color.FromName("Red");
                    //PKM
                    pnlAdded.ForeColor = Color.White;
                    pnlAdded.Attributes.Add("onmouseover", "javascript:this.style.backgroundColor = 'Yellow';this.style.color = 'Black';");
                    //PKM CHANGED backgroundColor
                    pnlAdded.Attributes.Add("onmouseout", "javascript:this.style.backgroundColor = '"+Red+"';this.style.color = 'White';");
                    //PKM
                    pnlAdded.Attributes.Add("onclick", "openWin('" + e.Item.ClientID + "','" + event_id + "'); return false");

                    pnlAdded.Controls.Add(new LiteralControl("<hr>"));

                    target_panel.Controls.Add(pnlAdded);

                    #region Dynamically Creating HoverMenuExtender for the Appointment Literals

                    //Creating HoverMenu Panel
                    Panel pnlHover = new Panel();
                    pnlHover.ID = "pnlHover" + Guid.NewGuid().ToString();

                    //Adding Controls to the HoverMenu Panel
                    //Appt Title Label
                    Label lblAppTitle = new Label();
                    lblAppTitle.ID = "AppTitle" + Guid.NewGuid().ToString();
                    lblAppTitle.Font.Bold = true;
                    lblAppTitle.Text = "Appointment&nbsp;Title:";
                    pnlHover.Controls.Add(lblAppTitle);
                    //End
                    pnlHover.Controls.Add(new LiteralControl("<br />&nbsp;&nbsp;"));
                    //ApptTime Value Label
                    Label lblAppTitleVal = new Label();
                    lblAppTitleVal.ID = "AppTitleVal" + Guid.NewGuid().ToString();
                    lblAppTitleVal.Text = event_title;
                    pnlHover.Controls.Add(lblAppTitleVal);
                    //End
                    pnlHover.Controls.Add(new LiteralControl("<br />"));
                    //ApptType Label
                    Label lblAppType = new Label();
                    lblAppType.ID = "AppType" + Guid.NewGuid().ToString();
                    lblAppType.Font.Bold = true;
                    lblAppType.Text = "Appointment&nbsp;Type:";
                    pnlHover.Controls.Add(lblAppType);
                    //End
                    pnlHover.Controls.Add(new LiteralControl("<br />&nbsp;&nbsp;"));
                    //ApptType Value Label
                    Label lblAppTypeVal = new Label();
                    lblAppTypeVal.ID = "AppTypeVal" + Guid.NewGuid().ToString();
                    lblAppTypeVal.Text = event_AppointmentType;
                    pnlHover.Controls.Add(lblAppTypeVal);
                    //End
                    pnlHover.Controls.Add(new LiteralControl("<br />"));
                    //Patient Name Label
                    Label lblPatName = new Label();
                    lblPatName.ID = "PatName" + Guid.NewGuid().ToString();
                    lblPatName.Font.Bold = true;
                    lblPatName.Text = "Patient&nbsp;Name:";
                    pnlHover.Controls.Add(lblPatName);
                    //End
                    pnlHover.Controls.Add(new LiteralControl("<br />&nbsp;&nbsp;"));
                    //Patient Name Value Label
                    Label lblPatNameVal = new Label();
                    lblPatNameVal.ID = "PatNameVal" + Guid.NewGuid().ToString();
                    lblPatNameVal.Text = event_PatLastName + " " + event_PatFirstName;
                    pnlHover.Controls.Add(lblPatNameVal);
                    //End
                    pnlHover.Controls.Add(new LiteralControl("<br />"));
                    //ApptDesc Label
                    Label lblAppDesc = new Label();
                    lblAppDesc.ID = "AppDesc" + Guid.NewGuid().ToString();
                    lblAppDesc.Font.Bold = true;
                    lblAppDesc.Text = "Description:";
                    pnlHover.Controls.Add(lblAppDesc);
                    //End
                    pnlHover.Controls.Add(new LiteralControl("<br />&nbsp;&nbsp;"));
                    //ApptDesc Value Label
                    Label lblAppDescVal = new Label();
                    lblAppDescVal.ID = "AppDescVal" + Guid.NewGuid().ToString();
                    lblAppDescVal.Text = event_desc;
                    pnlHover.Controls.Add(lblAppDescVal);
                    //End
                    pnlHover.Controls.Add(new LiteralControl("<br />"));
                    //ApptParticipants Label
                    Label lblAppParticipants = new Label();
                    lblAppParticipants.ID = "AppParticipants" + Guid.NewGuid().ToString();
                    lblAppParticipants.Font.Bold = true;
                    lblAppParticipants.Text = "Participants:";
                    pnlHover.Controls.Add(lblAppParticipants);
                    //End
                    pnlHover.Controls.Add(new LiteralControl("<br />&nbsp;&nbsp;"));
                    //ApptParticipants Value Label
                    Label lblAppParticipantsVal = new Label();
                    lblAppParticipantsVal.ID = "AppParticipantsVal" + Guid.NewGuid().ToString();
                    if (event_ParticipantsText.Contains(","))
                    {
                        foreach (string names in event_ParticipantsText.Split(",".ToCharArray()))
                        {
                            lblAppParticipantsVal.Text += names + "<br />&nbsp;&nbsp;";
                        }
                    }
                    else
                    {
                        lblAppParticipantsVal.Text = event_ParticipantsText + "<br />";
                    }
                    pnlHover.Controls.Add(lblAppParticipantsVal);
                    //End
                    //pnlHover.Controls.Add(new LiteralControl("<br />"));
                    //Adding controls to Panel End
                    target_panel.Controls.Add(pnlHover);
                    pnlHover.CssClass = "popupMenu";

                    AjaxControlToolkit.HoverMenuExtender hm1 = new AjaxControlToolkit.HoverMenuExtender();
                    hm1.ID = "hm" + Guid.NewGuid().ToString();
                    hm1.TargetControlID = pnlAdded.ID;
                    hm1.PopupControlID = pnlHover.ID;
                    hm1.PopupPosition = AjaxControlToolkit.HoverMenuPopupPosition.Bottom;
                    hm1.PopDelay = 50;
                    hm1.OffsetX = 0;
                    hm1.OffsetY = 0;
                    hm1.HoverDelay = 5;
                    pnlHover.Controls.Add(hm1);

                    #endregion
                }
            }
        }