Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now