Solved

Using the calendar tool for asp.net

Posted on 2010-08-31
6
599 Views
Last Modified: 2012-05-10
Hello, currently I using a dropdown box to hold dates to use the query information. I have a start date and a end date. I want to convert this to a calendar function but I'm getting the following errors:

System.web.ui.webcontrols.calendar does not contain a definition for "DataSource"
System.web.ui.webcontrols.calendar does not contain a definition for "DataValueField"
System.web.ui.webcontrols.calendar does not contain a definition for "DataTextField"

I'm still learning some of this .net stuff and I'm taking over for someone so I need a little help to fix this issue for production. Below is the code of the aspx.cs file. What do I need to change so that I can use the dates from database to collorate with the calendar. The format of the dates is 8/23/2010. Thanks!!
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.Common;

public partial class customerContractUsage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Roles.IsUserInRole("Admin") && !Roles.IsUserInRole("Poster") && !Roles.IsUserInRole("Customer")) Response.Redirect("default.aspx");

        Database dbMW = DatabaseFactory.CreateDatabase("MW_WebDataSource");
        Database dbRMS = DatabaseFactory.CreateDatabase("RMS_DataSource");

        //If the database is being updated display this message
        lblUpdating.Visible = ("Y" == "" + dbMW.ExecuteScalar(dbMW.GetSqlStringCommand("SELECT update_status FROM GLOBALSETTINGS")));

        if (!IsPostBack)
        {
            //Fill DDL Date Lists

            // ****** Is Technology  ******
            String sessBAID = Session["BAID"].ToString();
            DbCommand cmd = dbRMS.GetSqlStringCommand("Select Distinct(CONVERT(VARCHAR(7),ObligationFromDate,120)) Date, Replace(RIGHT(CONVERT(VARCHAR(11),ObligationFromDate,113), 8), ' ', '-') DisplayDate From RMS.rms_dbo.ra_OBLIGATIONS Where BAID = @sessBAID Order By CONVERT(VARCHAR(7),ObligationFromDate,120) Desc");
            dbRMS.AddInParameter(cmd, "@sessBAID", DbType.String, sessBAID);
            DataSet ds = dbRMS.ExecuteDataSet(cmd);
            //String ddlSQL = "Select Distinct(CONVERT(VARCHAR(7),ObligationFromDate,120)) Date, Replace(RIGHT(CONVERT(VARCHAR(11),ObligationFromDate,113), 8), ' ', '-') DisplayDate From RMS.rms_dbo.ra_OBLIGATIONS Where BAID = " + Session["BAID"] + " Order By CONVERT(VARCHAR(7),ObligationFromDate,120) Desc";
            //DataSet ds = dbRMS.ExecuteDataSet(dbRMS.GetSqlStringCommand(ddlSQL));
            // ****** Is Technology  ******

            ddlStartDate.DataSource = ds;
            ddlStartDate.DataValueField = "Date";
            ddlStartDate.DataTextField = "DisplayDate";
            ddlStartDate.DataBind();
            ddlEndDate.DataSource = ds;
            ddlEndDate.DataValueField = "Date";
            ddlEndDate.DataTextField = "DisplayDate";
            ddlEndDate.DataBind();
        }
        else
        {
            //We have a post back, read the data!
        }
    }
}

Open in new window

0
Comment
Question by:DancingFighterG
  • 3
  • 2
6 Comments
 
LVL 9

Expert Comment

by:sevensnake77
ID: 33568788
Not understanding --
>>What do I need to  change so that I can use the dates from database to collorate with the  calendar. The format of the dates is 8/23/2010

do you want to set the format?
do you want to use todays date what ever today may be.

0
 

Author Comment

by:DancingFighterG
ID: 33568876
I want to use the calendar to selet dates instead of using a dropdown box that has dates populated in them from the databases.
0
 
LVL 9

Accepted Solution

by:
sevensnake77 earned 500 total points
ID: 33569218
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
foreach(DateTime dt in Calendar1.SelectedDates)
{
Response.Write(dt.ToString() +"<BR>");
}
}

<asp:Calendar ID="Calendar1" runat="server"  onselectionchanged="Calendar1_SelectionChanged"  SelectionMode="DayWeekMonth"></asp:Calendar>

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
foreach(DateTime dt in Calendar1.SelectedDates)
{
Response.Write(dt.ToString() +"<BR>");
}
}

http://www.w3schools.com/aspnet/control_calendar.asp

I am not sure I helped you on this. but above code should help you as a starting point.
0
 

Author Comment

by:DancingFighterG
ID: 33569319
The following lines is binding the values from the database to these ids:

ddlStartDate.DataSource = ds;
ddlStartDate.DataValueField = "Date";
ddlStartDate.DataTextField = "DisplayDate";
ddlStartDate.DataBind();
ddlEndDate.DataSource = ds;
ddlEndDate.DataValueField = "Date";
ddlEndDate.DataTextField = "DisplayDate";
ddlEndDate.DataBind();

Now from the error htat I am gettting:

System.web.ui.webcontrols.calendar does not contain a definition for "DataSource"
System.web.ui.webcontrols.calendar does not contain a definition for "DataValueField"
System.web.ui.webcontrols.calendar does not contain a definition for "DataTextField"

Are not compatiable with the calander function. Is that correct?
0
 

Author Comment

by:DancingFighterG
ID: 33569579
I was looking at the following page:

http://demo.mediachase.com/calendar.net/DataBinding/DataBinding.aspx

it states that the calendar supports the Datasource defintion but I'm still getting errors
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Change to file doesn't show up 16 73
Phone Does Not Abide By CSS Breakpoint For Navigation Controls 6 32
Asp.Net Session Question 2 33
Web page design problem 3 11
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 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