Date picker not updating

3 posts, 0 answers
  1. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 02 Dec 2009 Link to this post

    I have a two date pickers on a page. They allow the user to select a from and to date. My page then queries a database and returns all entries within that date range. The page is working fine when you select the date for the first time. However if you change anything and try to submit again the date stays the same as the first time that you picked. Does anyone have any idea why. You can see it here

    Here is my aspx
    <%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/MasterPage.Master"
        CodeBehind="printSelect.aspx.vb" Inherits="ClickableCommunity.printSelect" %>

    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <asp:Content ID="Content2" ContentPlaceHolderID="headerContent" runat="server">
    <asp:Content ID="Content3" ContentPlaceHolderID="viewMenuContent" runat="server">
    <asp:Content ID="Content4" ContentPlaceHolderID="leftMenu" runat="server">
    <asp:Content ID="Content5" ContentPlaceHolderID="mainContentPlaceHolder" runat="server">
        <telerik:RadFormDecorator ID="formSkin" runat="server" Skin="Web20" DecoratedControls="Buttons" />
        <div style="padding-top: 20px; padding-left: 20px;">
            <h3>Print Events</h3>        
            <table cellpadding="5">
                        <telerik:RadDatePicker ID="startDate" runat="server" Skin="Web20">
                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="startDate"
                            ErrorMessage="Please enter a start date." CssClass="errorMessage" Display="Dynamic"></asp:RequiredFieldValidator>
                        <telerik:RadDatePicker ID="finishDate" runat="server" Skin="Web20">
                        <asp:RequiredFieldValidator runat="server" ID="Requiredfieldvalidator2" ControlToValidate="finishDate"
                            ErrorMessage="Please select an end date." Display="Dynamic"></asp:RequiredFieldValidator>
                        <asp:CompareValidator ID="dateCompareValidator" runat="server" ControlToValidate="finishDate"
                            ControlToCompare="startDate" Operator="GreaterThan" Type="String" ErrorMessage="The end date must be later than the start date."
                            CssClass="errorMessage" Display="Dynamic">

            <asp:Button ID="print" Text="Print" runat="server" />
        <asp:Label ID="output" runat="server"></asp:Label>
    <asp:Content ID="Content6" ContentPlaceHolderID="footerContent" runat="server">

    And here is my vb
    Imports Telerik.Web.UI
    Imports System.Data
    Imports System.Data.Sql
    Imports System.Data.SqlClient

    Partial Public Class printSelect
        Inherits System.Web.UI.Page

        'my sql connection string
        Dim conn As String = System.Configuration.ConfigurationManager.ConnectionStrings("connectionString").ToString

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not (Page.IsPostBack) Then
                startDate.SelectedDate = Date.Now
            End If
        End Sub

        Private Sub print_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles print.Click

            Dim beginDate As Date = startDate.DbSelectedDate
            Dim stopDate As Date = finishDate.DbSelectedDate
            Dim html As String

            'my sql connection
            Dim myConn As New Data.SqlClient.SqlConnection(conn)

            'the name of the stored procedure
            Dim strSQL = "getEventsInRange"

            Dim returnCommand As New Data.SqlClient.SqlCommand(strSQL, myConn)

            'add the parameters
            returnCommand.Parameters.AddWithValue("@start", beginDate)
            returnCommand.Parameters.AddWithValue("@stop", stopDate)

            'tell the system it is a stored procedure
            returnCommand.CommandType = CommandType.StoredProcedure

                Dim dr As SqlDataReader = returnCommand.ExecuteReader()

                html = "<table cellpadding='3' border='0'><tr><td>" & beginDate.ToString & " test " & stopDate.ToString & "</td><td></td></tr>"

                While dr.Read()
                    '0, 1 description, 2,
                    '3 starttime, 4 stoptime, 5 locations.street, 6, 7 locations.state,
                    '8, 9,
                    html &= "<tr><td><h3>" & dr.Item(0) & "</h3></td></td></tr>" & _
                            "<tr><td>Start: </td><td>" & dr.Item(3) & "</td></tr>" & _
                            "<tr><td>Stop: </td><td>" & dr.Item(4) & "</td></tr>" & _
                            "<tr><td>Location: </td><td>" & dr.Item(2) & "</td></tr>" & _
                            "<tr><td>Address: </td><td>" & dr.Item(5) & " " & dr.Item(6) & ", " & dr.Item(7) & " " & dr.Item(8) & "</td></tr>" & _
                            "<tr><td>Website: </td><td>" & dr.Item(10) & "</td></tr>" & _
                            "<tr><td>Description: </td><td>" & dr.Item(1) & "</td></tr>" & _
                            "<tr><td>Category: </td><td>" & dr.Item(9) & "</td></tr>"

                End While 'while
                html += "</table>"
            Catch ex As Exception
                output.Text = ex.ToString

                'output.Text = ("<span class='textRed'>There was an error in retrieving the entity information,<br>" & _
                '               " please contact the system administrator if the problem persists.</span>")

            End Try
            If (output.Text = "") Then
                output.Text = html & "test"
            End If
        End Sub
    End Class

  2. Dimo
    Dimo avatar
    8450 posts

    Posted 03 Dec 2009 Link to this post


    Does this ring a bell?

    If (output.Text = "") Then
         output.Text = html & "test"
    End If

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 03 Dec 2009 Link to this post

    Of course it must have been too late in the day. Thanks,
Back to Top