<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>SQL Server</title>
        <link>http://weblogs.sqlteam.com/jhermiz/category/258.aspx</link>
        <description>SQL Server</description>
        <language>en-US</language>
        <copyright>Jon Hermiz</copyright>
        <managingEditor>Jon.Hermiz@thyssenkrupp.com</managingEditor>
        <generator>Subtext Version 1.9.4.0</generator>
        <item>
            <title>How To Set Default Dates In Reporting Services</title>
            <link>http://weblogs.sqlteam.com/jhermiz/archive/2008/03/26/How-To-Set-Default-Dates-In-Reporting-Services.aspx</link>
            <description>&lt;p&gt;I posted this in the SQL Team forum: &lt;font face="Arial"&gt;&lt;a href="http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=99696"&gt;http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=99696&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;It shows you a good way of creating a bunch of date functions so that you can use them in reporting services as date default values for any date parameter.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/jhermiz/aggbug/60555.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jon Hermiz</dc:creator>
            <guid>http://weblogs.sqlteam.com/jhermiz/archive/2008/03/26/How-To-Set-Default-Dates-In-Reporting-Services.aspx</guid>
            <pubDate>Wed, 26 Mar 2008 15:53:10 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/jhermiz/comments/60555.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/jhermiz/archive/2008/03/26/How-To-Set-Default-Dates-In-Reporting-Services.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/jhermiz/comments/commentRss/60555.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How To Create A Sharepoint Like Calendar In ASP.net</title>
            <link>http://weblogs.sqlteam.com/jhermiz/archive/2007/12/17/How-To-Create-A-Sharepoint-Like-Calendar-In-ASP.net.aspx</link>
            <description>&lt;p&gt;This article relates to a couple of articles that are on the site.  The original article was "Cool Tricks With The ASP.net Calendar".  You can find this here: &lt;font face="Arial"&gt;&lt;a href="http://weblogs.sqlteam.com/jhermiz/archive/2007/12/10/Cool-Tricks-With-The-ASP.net-Calendar.aspx"&gt;http://weblogs.sqlteam.com/jhermiz/archive/2007/12/10/Cool-Tricks-With-The-ASP.net-Calendar.aspx&lt;/a&gt;.  The other article you might find useful is the "Additional Tip For that Calendar Control In ASP.net" this article can be found here: &lt;font face="Arial"&gt;&lt;a href="http://weblogs.sqlteam.com/jhermiz/archive/2007/12/11/Additional-Tip-For-That-Calendar-Control-In-ASP.net.aspx"&gt;http://weblogs.sqlteam.com/jhermiz/archive/2007/12/11/Additional-Tip-For-That-Calendar-Control-In-ASP.net.aspx&lt;/a&gt;. &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Have you ever wanted to create a nice calendar control much like the sharepoint calendar control?  You know the calendar control with hyperlink data directly on each calendar day.  The previous articles shows you how to use the DayRender Calendar control event to add image controls.  But what about adding hyperlink controls as well as setting the NavigateURL property for each hyperlink to take you to another web page.&lt;/p&gt;
&lt;p&gt;This process is very similiar to the second article where we added image controls to a calendar control.  Now we want to simply add hyperlink controls.&lt;/p&gt;
&lt;p&gt;To do this drag and drop a calendar control on your web page.  Use your SQL knowledge to pull some data (with the date for each row of data) from your database table.  Store this data in a datatable or a dataset.  Then loop through your data and compare the date in your dataset / datatable with the day in the Calendar_DayRender event.  If they are equal instantiate a Hyperlink object.  Set its text property, its navigateurl property and whether or not you want a border.&lt;/p&gt;
&lt;p&gt;From our previous examples here's some code to help you out:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre&gt;Protected Sub Calendar13_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar13.DayRender
        Dim nextDate As DateTime
        Dim hl As HyperLink
        Dim onmouseoverStyle As String = "this.style.backgroundColor='#D4EDFF'"
        Dim onmouseoutStyle As String = "this.style.backgroundColor='@BackColor'"
        Dim rowBackColor As String = String.Empty
        Dim notTouched As Boolean

        notTouched = True
        Try
            If Not CType(Session("dsHolidays"), DataSet) Is Nothing Then
                For Each dr As DataRow In CType(Session("dsHolidays"), DataSet).Tables(0).Rows
                    nextDate = CType(dr("HolidayDate"), DateTime)
                    If nextDate = e.Day.Date Then
                        e.Cell.BackColor = System.Drawing.Color.Pink
                        e.Cell.ForeColor = System.Drawing.ColorTranslator.FromHtml("#24618E")
                        notTouched = False
                    End If
                Next
            End If

            If Not CType(Session("dsRequests2"), DataSet) Is Nothing Then
                For Each dr As DataRow In CType(Session("dsRequests2"), DataSet).Tables(0).Rows
                    nextDate = CType(dr("VacationDate"), DateTime)
                    If nextDate = e.Day.Date Then&lt;strong&gt;
                        hl = New HyperLink
                        hl.Text = CType(dr("ToolTip"), String)
                        hl.NavigateUrl = "Entry.aspx?ID=" &amp;amp; CType(dr("VacationID"), String)
                        hl.BorderColor = Color.Gray
                        hl.BorderWidth = 1
                        hl.ToolTip = "Click this item to get more detailed information."
                        hl.Font.Name = "Arial Narrow"
                        hl.Font.Bold = False
                        hl.ForeColor = System.Drawing.ColorTranslator.FromHtml("#24618E")
                        e.Cell.BackColor = Color.Azure
                        e.Cell.Controls.Add(hl) &lt;/strong&gt;
                        notTouched = False
                    End If
                Next
            End If

            If notTouched And Not e.Day.IsWeekend Then
                e.Cell.Attributes.Add("onmouseover", onmouseoverStyle)
                e.Cell.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor))
            End If
        Catch ex As Exception
            Response.Write("Errors occurred: No RuleID / Hire Date specified for user!  " &amp;amp; "Additional errors include: " &amp;amp; ex.ToString())
        End Try
        
    End Sub&lt;/pre&gt;
&lt;p&gt;The result:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://img264.imageshack.us/img264/6677/testyrc8.gif" /&gt;&lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/jhermiz/aggbug/60431.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jon Hermiz</dc:creator>
            <guid>http://weblogs.sqlteam.com/jhermiz/archive/2007/12/17/How-To-Create-A-Sharepoint-Like-Calendar-In-ASP.net.aspx</guid>
            <pubDate>Mon, 17 Dec 2007 14:01:49 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/jhermiz/comments/60431.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/jhermiz/archive/2007/12/17/How-To-Create-A-Sharepoint-Like-Calendar-In-ASP.net.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/jhermiz/comments/commentRss/60431.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Additional Tip For That Calendar Control In ASP.net</title>
            <link>http://weblogs.sqlteam.com/jhermiz/archive/2007/12/11/Additional-Tip-For-That-Calendar-Control-In-ASP.net.aspx</link>
            <description>&lt;p&gt;Regarding my post about the &lt;a href="http://weblogs.sqlteam.com/jhermiz/archive/2007/12/10/Cool-Tricks-With-The-ASP.net-Calendar.aspx"&gt;tips and tricks with the ASP.net calendar control&lt;/a&gt; someone emailed me asking how to add additional text / images to the calendar control to give the calendar day a more appealing visual representation.&lt;/p&gt;
&lt;p&gt;Something to this effect:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://img405.imageshack.us/img405/6263/imagesgo0.gif" /&gt;&lt;/p&gt;
&lt;p&gt;You handle images like so in the same event as we discussed before.  The event you want to use for this is the &lt;strong&gt;DayRender&lt;/strong&gt; event since you want to control each &lt;strong&gt;day&lt;/strong&gt;.  Anytime you need to handle something that is associated with a single day cell you have to take care of it in the day render event.  &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How To Do This&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I assume the reader has a good understanding of ASP.net, the web, and SQL.  In my case I had some fields to store a request status.  A request can be in three states:&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Pending (yellow question mark) &lt;/li&gt;
    &lt;li&gt;Approved (green check mark) &lt;/li&gt;
    &lt;li&gt;Declined (a red x) &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So in my previous post I showed you how to pull the requests from the SQL database.  Remember you do not have to do it this way, I am just showing you an example.  So in the DayRender event declare an Image web control:&lt;/p&gt;
&lt;p&gt;Dim s as System.Web.UI.WebControls.Image&lt;/p&gt;
&lt;p&gt;Then perform the following:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;Instantiate the object &lt;/li&gt;
    &lt;li&gt;Set its image url property &lt;/li&gt;
    &lt;li&gt;Set a tooltip (optional) &lt;/li&gt;
    &lt;li&gt;Add the image object to the Controls collection of e ( e.Cell.Controls.Add) &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So here we go:&lt;/p&gt;
&lt;p&gt;s = New System.Web.UI.WebControls.Image()&lt;/p&gt;
&lt;p&gt;With s&lt;/p&gt;
&lt;p&gt;  .ImageUrl = "~/images/yourimage.gif"&lt;/p&gt;
&lt;p&gt;  .ToolTip = "Some tool tip"&lt;/p&gt;
&lt;p&gt;End With&lt;/p&gt;
&lt;p&gt;e.Cell.Controls.Add(s)&lt;/p&gt;
&lt;p&gt;In my case I store some tool tip information inside of the actual database by concatenating some fields together and bringing them back in a stored procedure.  That way I can set the tool tip with some text that may be valuable to the end user.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="http://weblogs.sqlteam.com/jhermiz/archive/2007/12/10/Cool-Tricks-With-The-ASP.net-Calendar.aspx"&gt;From Our Previous Example&lt;/a&gt;&lt;/strong&gt; &lt;/p&gt;
&lt;pre&gt;Protected Sub Calendar13_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar13.DayRender
        Dim nextDate As DateTime
        Dim onmouseoverStyle As String = "this.style.backgroundColor='#D4EDFF'"
        Dim onmouseoutStyle As String = "this.style.backgroundColor='@BackColor'"
        Dim rowBackColor As String = String.Empty
        Dim notTouched As Boolean
        Dim s As System.Web.UI.WebControls.Image

        notTouched = True

        Try
            If Not CType(Session("dsRequests"), DataSet) Is Nothing Then
                For Each dr As DataRow In CType(Session("dsRequests"), DataSet).Tables(0).Rows
                    nextDate = CType(dr("VacationDate"), DateTime)
                    If nextDate = e.Day.Date Then
                        e.Cell.BackColor = System.Drawing.ColorTranslator.FromHtml(CType(dr("HTMLColor"), String))

                        Select Case (CType(dr("VacationStatusID"), String))
                            Case "Pending"
                                s = New System.Web.UI.WebControls.Image()
                                s.ImageUrl = "~/images/p.gif"
                                s.ToolTip = CType(dr("ToolTip"), String)
                                e.Cell.Controls.Add(s)

                            Case "Approved"
                                s = New System.Web.UI.WebControls.Image()
                                s.ImageUrl = "~/images/a.gif"
                                s.ToolTip = CType(dr("ToolTip"), String)
                                e.Cell.Controls.Add(s)

                            Case "Declined"
                                s = New System.Web.UI.WebControls.Image()
                                s.ImageUrl = "~/images/d.gif"
                                s.ToolTip = CType(dr("ToolTip"), String)
                                e.Cell.Controls.Add(s)
                            Case Else
                        End Select

                        notTouched = False
                    End If
                Next
            End If

            If notTouched And Not e.Day.IsWeekend Then
                e.Cell.Attributes.Add("onmouseover", onmouseoverStyle)
                e.Cell.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor))
            End If

        Catch ex As Exception
            Response.Write("Errors occurred: No RuleID / Hire Date specified for user!  " &amp;amp; "Additional errors include: " &amp;amp; ex.ToString())
        End Try
    End Sub
&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/jhermiz/aggbug/60427.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jon Hermiz</dc:creator>
            <guid>http://weblogs.sqlteam.com/jhermiz/archive/2007/12/11/Additional-Tip-For-That-Calendar-Control-In-ASP.net.aspx</guid>
            <pubDate>Tue, 11 Dec 2007 20:25:24 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/jhermiz/comments/60427.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/jhermiz/archive/2007/12/11/Additional-Tip-For-That-Calendar-Control-In-ASP.net.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/jhermiz/comments/commentRss/60427.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Cool Tricks With The ASP.net Calendar </title>
            <link>http://weblogs.sqlteam.com/jhermiz/archive/2007/12/10/Cool-Tricks-With-The-ASP.net-Calendar.aspx</link>
            <description>&lt;p&gt;&lt;strong&gt;UPDATE: Additional tips: &lt;font face="Arial"&gt;&lt;a href="http://weblogs.sqlteam.com/jhermiz/archive/2007/12/11/Additional-Tip-For-That-Calendar-Control-In-ASP.net.aspx"&gt;More Tips&lt;/a&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Been A Long Time&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Hello world...sorry I haven't posted in quite some time, we've been real busy at home this Christmas season.  Anyhow I thought I would share some tricks and tips with using the calendar control before you or your company spends some change to buy a control on the internet.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What Is The ASP.NET Calendar Control&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The ASP.net calendar control is simply the calendar that comes prepackaged with visual studio and is available as a standard control.  Here she is on the standard control:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://img513.imageshack.us/img513/7/calcontrolju4.gif" /&gt;&lt;/p&gt;
&lt;p&gt;And here is what the calendar control may look like:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://img129.imageshack.us/img129/4420/calendarrk4.gif" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Problem&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You have been tasked to create a time off tool request involving some pretty complicated things.  Your boss has asked for numerous features in this tool which you hoped he had never asked.  &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Da Boss&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://img233.imageshack.us/img233/4896/bossso1.gif" /&gt; &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;I want it to highlight specific days signaling holidays or time off requests. This helps me visualize what type of day the request is.   Color coding is a plus :-). &lt;/li&gt;
    &lt;li&gt;I'd like some nice mouse over effect on days that are not requested.  This helps the user notice a clickable type of cell. &lt;/li&gt;
    &lt;li&gt;O I dunno...I'd like to not only see a monthly view, but a yearly view so that I can quickly glance over an entire year for an employee. &lt;/li&gt;
    &lt;li&gt;O well...I dunno...Impress me...maybe allow a user to click a day on the calendar and have it go to a page with that calendar day being selected. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Umm you know the &lt;strong&gt;&lt;em&gt;simple &lt;/em&gt;&lt;/strong&gt;things..besides you have all the tools that the company has purchased for you.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;You&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://img127.imageshack.us/img127/148/youtz6.gif" /&gt;&lt;/p&gt;
&lt;p&gt;Thoughts to self: ***&lt;strong&gt;O NO NOT THE CALENDAR CONTROL...BUT CANT WE JUST BUY SOMETHING PRE MADE***&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Boss&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://img233.imageshack.us/img233/4896/bossso1.gif" /&gt;&lt;/p&gt;
&lt;p&gt;O by the way...we don't have any money to buy any third party tools...have a great day.  Don't forget to e-mail when its all done.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;You&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://img127.imageshack.us/img127/148/youtz6.gif" /&gt;&lt;/p&gt;
&lt;p&gt;O certainly boss...*cringe*...this should be no sweat *thank God I wore deodorant*.  Quickly images begin flashing in your head about what your boss said:&lt;/p&gt;
&lt;p&gt;"I want it to highlight specific days signaling holidays or time off requests. This helps me visualize what type of day the request is.   Color coding is a plus :-)."&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://img86.imageshack.us/img86/1786/calendarcolorfl4.gif" /&gt;&lt;/p&gt;
&lt;p&gt;"I'd like some nice mouse over effect on days that are not requested.  This helps the user notice a clickable type of cell."&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://img129.imageshack.us/img129/493/testtq7.gif" /&gt;&lt;/p&gt;
&lt;p&gt;"O I dunno...I'd like to not only see a monthly view, but a yearly view so that I can quickly glance over an entire year for an employee."&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://img129.imageshack.us/img129/7808/yearlycr3.gif" /&gt;&lt;/p&gt;
&lt;p&gt;"O well...I dunno...Impress me...maybe allow a user to click a day on the calendar and have it go to a page with that calendar day being selected."&lt;/p&gt;
&lt;p&gt;**Ok that one is simple response.redirect and send a query string**&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://img127.imageshack.us/img127/148/youtz6.gif" /&gt;How in the world am I going to do all of these with the ASP.net calendar control?  That control is just so dull, so plain, difficult to use.  &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Got To Get To Work&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Well the ASP.net calendar control is pretty limited, its got a few events you can hook onto.  In fact when I started writing code using this control I was pretty upset because the control just seemed plain, really stale, didn't live up to my expectations.  But I was forced to use it.  Sure you can probably spend 100-200 bucks on a &lt;a href="http://www.telerik.com/"&gt;RAD Control&lt;/a&gt;...but do you really need to.  Most everything the &lt;strong&gt;Boss&lt;/strong&gt; wants is right there in the calendar control.  So lets tackle it one step at a time.&lt;/p&gt;
&lt;p&gt;Lets do the simple one first.  Before we begin, I am putting a caution that this code may need to be cleaned, this could o r could not be production code, it is merely a sample.  Samples help beginners and even advanced programmers learn how they can accomplish a specific task.  So take what you need and modify to fit your needs.  &lt;strong&gt;DO NOT EMAIL ME SAYING HOW BAD / GOOD IT IS TO DO A SPECIFIC THING.  TAKE WHAT YOU NEED AND RUN!!!  &lt;/strong&gt;Ok done with the rant.  Now lets take the simple example of how to create the rollover effect of the calendar.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Rollover Effect&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;At first you might think to use the PreRender event to handle this.  The problem with the PreRender event in this case will cause your entire calendar to highlight a specific color when you roll over it.  To avoid this let's use the DayRender event this will ensure that the rollover effect is per day and not per calendar.  To do this first decide what color you want to use to highlight the calendar when you rollover it (onMouseOver).  Then decide what color you want to highlight when you are off of the calendar day (onMouseOut).&lt;/p&gt;
&lt;p&gt;In this case I will use a light shade of blue (almost a baby blue) as the onMouseOver color and I'll use white for the onMouseOut color.  You can use hex codes or named colors, both work using this code.  You can also obtain the default backcolor property using @BackColor.&lt;/p&gt;
&lt;p&gt;Heres some vb.net to help you:&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre&gt; Protected Sub Calendar13_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar13.DayRender
 	 Dim onmouseoverStyle As String = "this.style.backgroundColor='#D4EDFF'"
	 Dim onmouseoutStyle As String = "this.style.backgroundColor='@BackColor'"
	 Dim rowBackColor As String = String.Empty
            
	 e.Cell.Attributes.Add("onmouseover", onmouseoverStyle)
	 e.Cell.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor))
    
     If Not e.Day.IsWeekend Then
                e.Cell.Attributes.Add("onmouseover", onmouseoverStyle)
                e.Cell.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor))
     End If
 End Sub
&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt; So here all you're doing is setting a mouseOver for days that are not weekends.  The result:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://img129.imageshack.us/img129/493/testtq7.gif" /&gt;&lt;/p&gt;
&lt;p&gt;Ok so now that we are done with the highlight effect lets look at the example of color coding specific days.  &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Color Coding Specific Days In The ASP.net Calendar Control&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In this case I assume the reader knows how to use datatables, datasets, and common sql statements such as SELECT, INSERT, UPDATE, etc.  So assume you have a table that has time off requests.  In this table you have a field where you store the time off request date.  You want the days requested off visually displayed on the calendar control in a different color.  To do this you simply write a stored procedure to pull your data.  You then store this data inside of a datatable or a dataset.  Once you have done this you check the e.Day.Date property with the value stored in your data row value.  If the values match you handle this event and you change the e.Cell.BackColor.&lt;/p&gt;
&lt;p&gt;In my case I will use a dataset that is stored in a session variable.  You do not need to do it like this, this is just an example.  For instance, you may want to use a data table, or maybe you just want a dataset but you do not want to store it in a session variable.  In any event you preform this code yet again in the DayRender event of the calendar control.&lt;/p&gt;
&lt;p&gt;Here is some code that will help make more sense:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;hr /&gt;
&lt;pre&gt;Protected Sub Calendar13_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar13.DayRender 

        Dim nextDate As DateTime
 
        Try
               'this part is the actual time off requests
            If Not CType(Session("dsRequests"), DataSet) Is Nothing Then
                For Each dr As DataRow In CType(Session("dsRequests"), DataSet).Tables(0).Rows
                    nextDate = CType(dr("VacationDate"), DateTime)
                    If nextDate = e.Day.Date Then
                        e.Cell.BackColor = System.Drawing.ColorTranslator.FromHtml(CType(dr("HTMLColor"), String))
                  End If
                Next
            End If
 
        Catch ex As Exception
            Response.Write("Errors occurred: No RuleID / Hire Date specified for user! " &amp;amp; "Additional errors include: " &amp;amp; ex.ToString())
        End Try
    End Sub
&lt;/pre&gt;
&lt;hr /&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;&lt;span style="COLOR: blue"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt;&lt;span style="COLOR: blue"&gt;&lt;/span&gt;&lt;/span&gt;
&lt;p&gt;What's going on in this code.  Well first and foremost get rid of what you don't need and change field names, code based on your needs.  In my table I store a field called VacationDate this field has the date value of the time off request.  I assign this value to nextDate and compare nextDate with e.Day.Date.  If these values are the same then I set the e.Cell.BackColor to a color based on another field in my database HTMLColor.  You do not have to have this field, this field is used because in my circumstances we have many time off request types and I want to associate a hex color with each time off type.  You may want to only use a specific color like, &lt;font size="2"&gt;System.Drawing.Color.Red.  In this case you would do:&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;e.Cell.BackColor =  &lt;font size="2"&gt;System.Drawing.Color.Red&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;So the steps are:&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;Pull the data using a stored procedure, order it by date asc&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;
    &lt;li&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;Take this data and store it in a dataset or a datatable&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;
    &lt;li&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;Use the DayRender event to handle the event each day&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;
    &lt;li&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;Check if e.Day.Date is equal to your date that was returned from the database (dr("HolidayDate") from above)&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;
    &lt;li&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;If the values match up set the e.Cell.BackColor property to the color you want.  Better yet store a color hex value in your database for each type of time off request.&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;&lt;strong&gt;But I Used The DayRender Event For That OnMouseOver Effect Now What?&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;Simple, combine both together like so:&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;pre&gt;    Protected Sub Calendar13_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar13.DayRender
        Dim nextDate As DateTime
        Dim onmouseoverStyle As String = "this.style.backgroundColor='#D4EDFF'"
        Dim onmouseoutStyle As String = "this.style.backgroundColor='@BackColor'"
        Dim rowBackColor As String = String.Empty
        Dim notTouched As Boolean

        notTouched = True

        Try
            If Not CType(Session("dsHolidays"), DataSet) Is Nothing Then
                For Each dr As DataRow In CType(Session("dsHolidays"), DataSet).Tables(0).Rows
                    nextDate = CType(dr("HolidayDate"), DateTime)
                    If nextDate = e.Day.Date Then
                        e.Cell.BackColor = System.Drawing.Color.Pink
                        notTouched = False
                    End If
                Next
            End If

            If Not CType(Session("dsRequests"), DataSet) Is Nothing Then
                For Each dr As DataRow In CType(Session("dsRequests"), DataSet).Tables(0).Rows
                    nextDate = CType(dr("VacationDate"), DateTime)
                    If nextDate = e.Day.Date Then
                        e.Cell.BackColor = System.Drawing.ColorTranslator.FromHtml(CType(dr("HTMLColor"), String))
                        notTouched = False
                  End If
                Next
            End If

            If notTouched And Not e.Day.IsWeekend Then
                e.Cell.Attributes.Add("onmouseover", onmouseoverStyle)
                e.Cell.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor))
            End If

        Catch ex As Exception
            Response.Write("Errors occurred: No RuleID / Hire Date specified for user!  " &amp;amp; "Additional errors include: " &amp;amp; ex.ToString())
        End Try

    End Sub
&lt;/pre&gt;
&lt;hr /&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;strong&gt;&lt;img alt="" src="http://img129.imageshack.us/img129/493/testtq7.gif" /&gt; &lt;/strong&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;The OnMouseOver effect as well as the colored background cells on the 7th and the 25th of December 07.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;strong&gt;But What If I Am Using More Then One Calendar Control&lt;/strong&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;There is always those what if's.  You may be using more then one calendar control in your application, if you are no problem.  In this case create a sub routine to HANDLES all the calendar objects in your application.  For instance, assume you have 12 calendar controls then your subroutine signature should look like this:&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;hr /&gt;
&lt;/div&gt;
&lt;pre&gt;Private Sub DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender, Calendar2.DayRender, _ 
                          Calendar3.DayRender, Calendar4.DayRender, Calendar5.DayRender, Calendar6.DayRender, Calendar7.DayRender, Calendar8.DayRender, Calendar9.DayRender, _
                          Calendar10.DayRender, Calendar11.DayRender, Calendar12.DayRender
&lt;/pre&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;hr /&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;This shows one sub routine called DayRender which can handle the DayRender event of any of the 12 calendars.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;The rest of the code is very similiar to what we posted previously:&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;hr /&gt;
&lt;/div&gt;
&lt;pre&gt;Private Sub DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender, Calendar2.DayRender, _ 
                          Calendar3.DayRender, Calendar4.DayRender, Calendar5.DayRender, Calendar6.DayRender, Calendar7.DayRender, Calendar8.DayRender, Calendar9.DayRender, _
                          Calendar10.DayRender, Calendar11.DayRender, Calendar12.DayRender
 
        Dim nextDate As DateTime
        Dim cal As Calendar = CType(sender, Calendar)
        Dim onmouseoverStyle As String = "this.style.backgroundColor='#D4EDFF'"
        Dim onmouseoutStyle As String = "this.style.backgroundColor='@BackColor'"
        Dim rowBackColor As String = String.Empty
        Dim notTouched As Boolean
 
        notTouched = True
 
        If e.Day.Date.Month &amp;lt;&amp;gt; cal.TodaysDate.Month Then Exit Sub
 
        Try
            If Not CType(Session("dsRequests"), DataSet) Is Nothing Then
                For Each dr As DataRow In CType(Session("dsRequests"), DataSet).Tables(0).Rows
                    nextDate = CType(dr("VacationDate"), DateTime)
                    If nextDate = e.Day.Date Then
                        e.Cell.BackColor = System.Drawing.ColorTranslator.FromHtml(CType(dr("HTMLColor"), String))
                        notTouched = False
                    End If
                Next
            End If
 
            If notTouched And Not e.Day.IsWeekend Then
                e.Cell.Attributes.Add("onmouseover", onmouseoverStyle)
                e.Cell.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor))
            End If
 
        Catch ex As Exception
            Response.Write("Errors occurred: No RuleID / Hire Date specified for user! " &amp;amp; "Additional errors include: " &amp;amp; ex.ToString())
        End Try
    End Sub
&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;In this case we handle all 12 calendar controls.  The result is as follows:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://img513.imageshack.us/img513/3651/testyig8.gif" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Passing The Date To Another Page&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Suppose you want to pass a calendar day to a Response.Redirect to another page when you click on a calendar day.  Here you can simply pass a parameter to a page like so:&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Response.Redirect(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;"entry.aspx?VacationDate="&lt;/font&gt;&lt;font size="2"&gt; &amp;amp; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;CType&lt;/font&gt;&lt;font size="2"&gt;(Calendar13.SelectedDate, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;Date&lt;/font&gt;&lt;font size="2"&gt;))&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;And to pull that date in the entry.aspx page simply use the following:&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;font size="2"&gt;Dim d as Date&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;d&lt;font size="2"&gt; = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;CType&lt;/font&gt;&lt;font size="2"&gt;(Request(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;"VacationDate"&lt;/font&gt;&lt;font size="2"&gt;), &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;Date&lt;/font&gt;&lt;font size="2"&gt;) &lt;/font&gt;&lt;font color="#008000" size="2"&gt;'grab date&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Hope this helps someone out there who needs to do something similiar.&lt;span style="FONT-SIZE: 10pt"&gt;   &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt;&lt;span style="COLOR: blue"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;&lt;img src="http://weblogs.sqlteam.com/jhermiz/aggbug/60423.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jon Hermiz</dc:creator>
            <guid>http://weblogs.sqlteam.com/jhermiz/archive/2007/12/10/Cool-Tricks-With-The-ASP.net-Calendar.aspx</guid>
            <pubDate>Mon, 10 Dec 2007 17:16:28 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/jhermiz/comments/60423.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/jhermiz/archive/2007/12/10/Cool-Tricks-With-The-ASP.net-Calendar.aspx#feedback</comments>
            <slash:comments>10</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/jhermiz/comments/commentRss/60423.aspx</wfw:commentRss>
        </item>
        <item>
            <title>DevConnections 2007</title>
            <link>http://weblogs.sqlteam.com/jhermiz/archive/2007/08/20/DevConnections-2007.aspx</link>
            <description>&lt;p&gt;Count me in this year &lt;strong&gt;again!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I had an excellent time last year and met some real cool folks.&lt;/p&gt;
&lt;p&gt;I'll be in the visual studio asp.net conference along with the reporting services seminars.  Bring your RS questions if you have any.&lt;/p&gt;
&lt;p&gt;Here's some pics from last years: &lt;font face="Arial"&gt;&lt;a href="http://jhermiz.googlepages.com/devconnections2006"&gt;http://jhermiz.googlepages.com/devconnections2006&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;I wonder if Isaac Stubbs is still cruising in that motorcycle he won??  If you've never been to devconnections before then now is the time to go.  Tell your boss you need to attend &lt;a href="http://www.devconnections.com"&gt;www.devconnections.com&lt;/a&gt;.  You get a free copy of MS Visual Studio 2k8...you can easily make a case to your boss about going.  Most of you can write it off on your taxes as well; since this helps you do your daily job.&lt;/p&gt;
&lt;p&gt;See you there!&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/jhermiz/aggbug/60295.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jon Hermiz</dc:creator>
            <guid>http://weblogs.sqlteam.com/jhermiz/archive/2007/08/20/DevConnections-2007.aspx</guid>
            <pubDate>Mon, 20 Aug 2007 15:57:11 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/jhermiz/comments/60295.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/jhermiz/archive/2007/08/20/DevConnections-2007.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/jhermiz/comments/commentRss/60295.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to pull Sharepoint list data from SQL Server</title>
            <link>http://weblogs.sqlteam.com/jhermiz/archive/2007/08/15/60288.aspx</link>
            <description>Learn how to pull a sharepoint site's list data from SQL Server, click &lt;a href="http://weblogs.sqlteam.com/jhermiz/archive/2007/08/15/60288.aspx" target="_blank"&gt;here&lt;/a&gt; for more info.&lt;img src="http://weblogs.sqlteam.com/jhermiz/aggbug/60288.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jon Hermiz</dc:creator>
            <guid>http://weblogs.sqlteam.com/jhermiz/archive/2007/08/15/60288.aspx</guid>
            <pubDate>Wed, 15 Aug 2007 15:25:40 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/jhermiz/comments/60288.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/jhermiz/archive/2007/08/15/60288.aspx#feedback</comments>
            <slash:comments>10</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/jhermiz/comments/commentRss/60288.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Power of the ReportServer - How to pull data from Reporting Services Database</title>
            <link>http://weblogs.sqlteam.com/jhermiz/archive/2007/08/14/60285.aspx</link>
            <description>Learn &lt;a href="http://weblogs.sqlteam.com/jhermiz/archive/2007/08/14/60285.aspx" target="_blank"&gt;how to pull data&lt;/a&gt; from the Reporting Services database.&lt;img src="http://weblogs.sqlteam.com/jhermiz/aggbug/60285.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jon Hermiz</dc:creator>
            <guid>http://weblogs.sqlteam.com/jhermiz/archive/2007/08/14/60285.aspx</guid>
            <pubDate>Tue, 14 Aug 2007 19:02:48 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/jhermiz/comments/60285.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/jhermiz/archive/2007/08/14/60285.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/jhermiz/comments/commentRss/60285.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Pulling SAP Data From .NET</title>
            <link>http://weblogs.sqlteam.com/jhermiz/archive/2007/08/14/60282.aspx</link>
            <description>Learn how to pull data from SAP from a .net application and load it into sql server.

Read &lt;a href=" http://weblogs.sqlteam.com/jhermiz/archive/2007/08/14/60282.aspx" target="_blank"&gt; here&lt;/a&gt; for more info.&lt;img src="http://weblogs.sqlteam.com/jhermiz/aggbug/60282.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jon Hermiz</dc:creator>
            <guid>http://weblogs.sqlteam.com/jhermiz/archive/2007/08/14/60282.aspx</guid>
            <pubDate>Tue, 14 Aug 2007 18:04:30 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/jhermiz/comments/60282.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/jhermiz/archive/2007/08/14/60282.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/jhermiz/comments/commentRss/60282.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>