Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
protected void CalenderDRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
    {
        // If the month is CurrentMonth
        if (!e.Day.IsOtherMonth)
        {
            foreach (DataRow dr in ds.Tables[0].Rows) WHAT THIS LINE DO?  IF USE DATATEBLE WHAT IS THE CODE
            {
                if ((dr["EventDate"].ToString() != DBNull.Value.ToString()))WHAT IS DBNull.Value.toString
                {
                    DateTime dtEvent = (DateTime)dr["EventDate"]; WHAT THIS LINE DO?
                    if (dtEvent.Equals(e.Day.Date))
                    {
                        e.Cell.BackColor = Color.PaleVioletRed;
                    }
                }
            }
        }
        //If the month is not CurrentMonth then hide the Dates
        else
        {
            e.Cell.Text = "";
        }
    }
Posted
Comments
Toniyo Jackson 3-Jun-11 3:34am    
What is the problem you are facing?
Deepthi Aravind 3-Jun-11 3:36am    
Wht's the pbm?
Richard MacCutchan 3-Jun-11 4:33am    
What happened to the vowels on your keyboard?
Sergey Alexandrovich Kryukov 3-Jun-11 3:38am    
Not that it is not a question. Even if there is a question, it would be not quite appropriate. We're trying to help people who write their own code.
--SA

This line iterates over all the lines in the first table of the dataset.
C#
foreach (DataRow dr in ds.Tables[0].Rows)


This lines attempts to see if the value for the column named EventDate is null
C#
if ((dr["EventDate"].ToString() != DBNull.Value.ToString()))

but it's done incorrectly, it should be just this):
C#
if ((dr["EventDate"] != DBNull.Value))


This lines get the EventDate column out and casts it to a DateTime and stores that value in a local variable called dtEvent.
cs#
DateTime dtEvent = (DateTime)dr["EventDate"];


Hope this helps,
Fredrik
 
Share this answer
 
Comments
walterhevedeich 3-Jun-11 4:03am    
OK. You beat me to it. :). Have a 5.
Richard MacCutchan 3-Jun-11 4:06am    
Don't encourage him. This person keeps posting messages like this, but never responds or thanks anyone who offers help.
walterhevedeich 3-Jun-11 4:19am    
Are you referring to the OP? I didnt vote for the question.
Richard MacCutchan 3-Jun-11 4:32am    
Yes, sorry I should have clicked Add Comment rather than Reply to your message.
Fredrik Bornander 3-Jun-11 4:10am    
You snooze, you lose :)
OP wrote:
foreach (DataRow dr in ds.Tables[0].Rows) WHAT THIS LINE DO? IF USE DATATEBLE WHAT IS THE CODE

Actually, you are already using a data table here(ds.Tables[0]). The code is simply looping through every row in your table. Each row is assigned to dr.
OP wrote:
if ((dr["EventDate"].ToString() != DBNull.Value.ToString()))WHAT IS DBNull.Value.toString

DBNull.Value simply represents nonexistent values to the database. The toString method is not necessary.
OP wrote:
DateTime dtEvent = (DateTime)dr["EventDate"]; WHAT THIS LINE DO?

As I said a while ago, for every loop, each row from your data table is being assigned to dr. For that specific loop, the "EventDate" column of dr is being assigned to your dtEvent object.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900