Basic Date Picker Forums

Welcome to Basic Date Picker Forums Sign in | Join | Help
in Search

After set the selectedValue can't select other date

Last post 12-17-2009, 6:06 PM by Programming. 1 replies.
Sort Posts: Previous Next
  •  12-17-2009, 4:16 PM 1860

    After set the selectedValue can't select other date

    Hello ,

     

    I'm trying to populate my  BDPLite (d1_1) with dates from  database

    doing something like that ( part of my code)

    Dim cmdI As New SqlCommand("select date from Calendar where ID = @ID ", cs) \\ Ex. the result is 1\1\2010

    cmdI.Parameters.AddWithValue("@ID", ID)

    Dim dr As SqlDataReader =  cmdI.ExecuteReader()

    If dr.HasRows Then

    While dr.Read()

    If Not dr.IsDBNull(0) Then

    d1_1.SelectedValue = CDate(dr(0).ToString())

    End If

    End While

    End If

    Now i see the BDPLite (d1_1)  have 1\1\2010 in the textbox

    Then i wanna to allow the user to change the date ( re-select another date )

    Dim cmdU As New SqlCommand("UPDATE  Calendar  SET date=@Sdate WHERE  ID=@ID ", cs)

    cmdU.Parameters.AddWithValue("@ID", ID)

    cmdU.Parameters.AddWithValue("@Sdate", d1_1.SelectedValue) \\ here should be the new selected date 9\1\2010

    cmdU.ExecuteNonQuery()

    but what I found after that the database value doesn't chenged :\

    what is the problem here  ? I wanna the user

     

    * sorry for my poor English

  •  12-17-2009, 6:06 PM 1861 in reply to 1860

    Re: After set the selectedValue can't select other date

    I found the solution :D

    because i set the date in the load,  i must put this inside if statment with (Not Page.IsPostBack) as an condition

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

View as RSS news feed in XML
 
Powered by Community Server, by Telligent Systems