Solved

Using the calendar tool for asp.net

Posted on 2010-08-31
6
606 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 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 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