Solved

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

Posted on 2014-11-25
2
141 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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

810 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