Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 149
  • Last Modified:

asp.net calendar control how to display multiple datarows per day

Hi, I'm a little bit at a loss on how to display all events on a given day in a calendar control, I'm trying unsuccessfully to concatenate rows, but am just duplicating them, how can I get more than one row to display on a calendar day when there is more than one record per day?


protected void DayRender(object sender, DayRenderEventArgs e)
        {
            Style codeStyle = new Style();
            codeStyle.BackColor = System.Drawing.Color.LightGreen;
            
            DateTime nextDate;
            if (dsAgent1964 != null)
            {
                foreach (DataRow dr in dsAgent1964.Tables[0].Rows)
                {
                    nextDate = (DateTime)dr["Dte"];
                    if (nextDate == e.Day.Date)
                    {
                        String Dte = dr["Dte"].ToString();                        
                        String code = dr["Code"].ToString();

                        String pein = dr["C_id"].ToString();
                        Int32 idxRow = dsAgent1964.Tables[0].Rows.IndexOf(dr);
                        var id = "opener" + idxRow;                        
                       
                        e.Cell.Text = "<a href=\"#\" id=\"opener" + idxRow + "\" data-dte=\"" + dr["Dte"] + "\" data-code=\"" + dr["Code"] + "\" onclick=\"openDialog(this);\">" + dr["Code"].ToString() + "</a>";

                        if (e.Cell.Text != String.Empty)
                        {
                            e.Cell.Text += "<br>";
                        }

                        e.Cell.Text += "<a href=\"#\" id=\"opener" + idxRow + "\" data-dte=\"" + dr["Dte"] + "\" data-code=\"" + dr["Code"] + "\" onclick=\"openDialog(this);\">" + dr["Code"].ToString() + "</a>";

                        e.Cell.ApplyStyle(codeStyle);                        
                        e.Day.IsSelectable = true;
                        
                        
                    }
                }
            }

Open in new window

0
Scarlett72
Asked:
Scarlett72
  • 2
1 Solution
 
Scarlett72Author Commented:
Hi I was able to resolve this by changing this line here +=:
 e.Cell.Text += "<a href=\"#\" id=\"opener" + idxRow + "\" data-dte=\"" + dr["Dte"] + "\" data-code=\"" + dr["Code"] + "\" onclick=\"openDialog(this);\">" + dr["Code"].ToString() + "</a><br>";

Open in new window

0
 
Scarlett72Author Commented:
Re reading my last comment, also remove this part:

if (e.Cell.Text != String.Empty)
                        {
                            e.Cell.Text += "<br>";
                        }

                        e.Cell.Text += "<a href=\"#\" id=\"opener" + idxRow + "\" data-dte=\"" + dr["Dte"] + "\" data-code=\"" + dr["Code"] + "\" onclick=\"openDialog(this);\">" + dr["Code"].ToString() + "</a>";

Open in new window

0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now