Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-11-25
2
Medium Priority
?
147 Views
Last Modified: 2014-11-25
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
Comment
Question by:Scarlett72
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 

Accepted Solution

by:
Scarlett72 earned 0 total points
ID: 40465374
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
 

Author Comment

by:Scarlett72
ID: 40465377
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

URL rewriting in AWS CloudFront

A quick how-to guide to implement with a Lambda function!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question