?
Solved

Using the calendar tool for asp.net

Posted on 2010-08-31
6
Medium Priority
?
616 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 9

Expert Comment

by:Seven price
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:
Seven price earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

718 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