asp calendar datetime format

i have a calendar that displays the information for a date that has been selected on the calendar in a gridview.when a date starts with a zero ie 2009/12/07 nothing is displayed but works for my other dates like 2009/12/22.what am i missing?
here is my code
<asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged"
                                    BorderWidth="1px" NextPrevFormat="FullMonth" BackColor="White" Width="350px"
                                    ForeColor="Black" Height="190px" Font-Size="9pt" Font-Names="Verdana" BorderColor="White">
                                    <TodayDayStyle BackColor="#CCCCCC"></TodayDayStyle>
                                    <NextPrevStyle Font-Size="8pt" Font-Bold="True" ForeColor="#333333" VerticalAlign="Bottom">
                                    </NextPrevStyle>
                                    <DayHeaderStyle Font-Size="8pt" Font-Bold="True"></DayHeaderStyle>
                                    <SelectedDayStyle ForeColor="White" BackColor="#333399"></SelectedDayStyle>
                                    <TitleStyle Font-Size="12pt" Font-Bold="True" BorderWidth="4px" ForeColor="#333399"
                                        BorderColor="Black" BackColor="White"></TitleStyle>
                                    <OtherMonthDayStyle ForeColor="#999999"></OtherMonthDayStyle>
                                </asp:Calendar>
                                <span class="mainheading">Event Location and Dates</span><br />
                                <br />
                                <asp:GridView ID="CalendarList" runat="server" Width="450px" AutoGenerateColumns="False"
                                    CssClass="gridtable" CellPadding="5" BorderColor="#ff3300" BorderWidth="1px"
                                    BackColor="#FFFFFF">
                                    <AlternatingRowStyle BackColor="#F8F8F8" />
                                    <Columns>
                                        <asp:TemplateField HeaderText="EventLocation" HeaderStyle-CssClass="gridheading">
                                            <ItemTemplate>
                                                <asp:Label ID="EventLocLabel" runat="server" Text='<%# Eval("EventLocation") %>'>
                                                </asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="EventDate" HeaderStyle-CssClass="gridheading">
                                            <ItemTemplate>
                                                <asp:Label ID="EventDateLabel" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "EventDate") %>
'>
                                                </asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>

protected void Page_Load(object sender, EventArgs e)
    {
}
    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
 
        Calendar Calendar1 = (Calendar)Form.FindControl("Calendar1");
        string connCalendarString = ConfigurationManager.AppSettings["THConnectionString"];
        MySqlConnection cnxCalendar = new MySqlConnection(connCalendarString);
        cnxCalendar.Open();
        MySqlDataAdapter adapterCalendar = new MySqlDataAdapter();
        string cmdCalendarText = ("SELECT EventLocation, EventDate FROM eventstable WHERE EventDate = ?EventDate");
        MySqlCommand cmdCalendar = new MySqlCommand(cmdCalendarText, cnxCalendar);
        cmdCalendar.Parameters.Add(new MySqlParameter("EventDate", Calendar1.SelectedDate.ToString("yyyy/MM/dd")));
        DataSet dsCalendar = new DataSet();
        adapterCalendar.SelectCommand = cmdCalendar;
        adapterCalendar.Fill(dsCalendar);
        GridView CalendarList = (GridView)Form.FindControl("CalendarList");
        CalendarList.DataSource = dsCalendar;
        CalendarList.DataBind();
    }
}


chrispatonAsked:
Who is Participating?
 
chrispatonAuthor Commented:
ok fixed it there was a problem with my database
0
 
Elvio Lujan.Net Senior DeveloperCommented:
can you set a break point in the line
cmdCalendar.Parameters.Add(new MySqlParameter("EventDate", Calendar1.SelectedDate.ToString("yyyy/MM/dd")));
and tell us what value you get with "Calendar1.SelectedDate" ??
0
 
chrispatonAuthor Commented:
hi,
the value is {07/12/2009 00:00:00}
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Elvio Lujan.Net Senior DeveloperCommented:
and why do you use the format "yyyy/MM/dd" intead "MM/dd/yyyy"???
0
 
chrispatonAuthor Commented:
That way seems to be the only way i have found so far that pulls any dates from my table
0
 
chrispatonAuthor Commented:
With the date as "MM/dd/yyyy" i get nothing returned.in my table the dates are stored as 2009-12-30
0
 
abelallenCommented:
Hi chrispaton,

Kindly navigate to the below url and let me know you got the exact solution for the problem...
http://www.obout.com/calendar/tutorial_titletext.aspx

Thanks,
Abel Allen
0
 
chrispatonAuthor Commented:
no it's still not pulling dates that start with a zero ie 2009/12/07
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.