Solved

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

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTML - Color not displaying correctly in EMAIL. 6 49
VB.Net WebRequest Code from JSON curl 7 53
Add a Condition in ASP Repeater 6 34
Finding the IIS version 5 22
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
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…

828 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