user1380485
user1380485

Reputation: 1

C# Calendar Tool ASP.NET

So I'm trying to create a calendar tool that pulls in dates from an SQL Database.

I've created a TableAdapter which is here: http://bit.ly/KRaTvr

This is the small bit of ASP I have to create my calendar:

<asp:Calendar ID="calEvents" runat="server"> </asp:Calendar>     

Then I have the C# in my project used to pull the information through.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using BreakyBottomTableAdapters;

public partial class Events : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {

        //Data Table
        BreakyBottom table;
        //Table Adapter
        BreakyBottomTableAdapters.ScheduleDate ta;
        ta = new BreakyBottomTableAdapters.ScheduleDate();
        //Populate the table using the Table Adapter passing current date
        table = ta.GetData(e.Day.Date);
        //Check the number of rows in the data table
        if (table.Rows.Count > 0)
        {
            //Change the background colour to gray
            e.Cell.BackColor = System.Drawing.Color.Gray;
            //Allow the Day to be selected
            e.Day.IsSelectable = true;
        }


    }
}

Now I know I'm missing something but I can't for the life of my figure out what it is.

Here is a screenshot of the compile error I get: http://bit.ly/ISuVsT - I know I'm probably missing something insanely obvious but any assistance would be appreciated.

Best Regards

Upvotes: 0

Views: 625

Answers (1)

Icarus
Icarus

Reputation: 63956

The compiler is telling you that EventArgs does not have any member called Day which you are apparently using in your code incorrectly:

protected void Page_Load(object sender, EventArgs e)
{
  ....
  table = ta.GetData(e.Day.Date); //WRONG: Day is not a member of EventArgs
}

If the idea is to use the Current date, as you mentioned, then do this:

   table = ta.GetData(DateTime.Now);

Upvotes: 1

Related Questions