Change Calendar selection based on data from the database (VB.net) : Calendar « Asp Control « ASP.Net

ASP.Net
1. ADO.net Database
2. Asp Control
3. Collections
4. Components
5. Data Binding
6. Development
7. HTML Control
8. Mobile Control
9. Page
10. Request
11. Response
12. Server
13. Session Cookie
14. User Control and Master Page
15. Validation by Control
16. Validation by Function
17. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
ASP.Net » Asp Control » Calendar 
Change Calendar selection based on data from the database (VB.net)

<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.SqlClient" %>

<html>
  <head><title>Calendar: Hire Dates</title></head>
  <body>
    <h3>Calendar: Hire Dates</h3>
    <form runat="server">
      <asp:ListBox id="lstEmployees" runat="server"
                   Rows="7"
                   Autopostback="True" /><br/>
      <asp:Label id="lblSelectedDate" runat="server" />
      <asp:Calendar id="calHire" runat="server"
                    SelectionMode = "None" />
    </form>
  </body>
</html>

<script language="VB" runat="server">
Sub Page_Load(Source As Object, E As EventArgs)
  Dim strConnection As String = ConfigurationSettings.AppSettings("YourDataName")
  Dim objConnection As New SqlConnection(strConnection)

  Dim strSQL As String = "SELECT ID, LastName, FirstName, HireDate FROM Employee;"

  Dim objAdapter As New SqlDataAdapter(strSQL, objConnection)
  Dim objDataSet As New DataSet("dsEmployees")
  objAdapter.Fill(objDataSet, "dtEmployees")

  If Not IsPostBack Then
    lstEmployees.DataSource = objDataSet
    lstEmployees.DataTextField = "LastName"
    lstEmployees.DataBind()
  Else
    Dim datHireDate As Date
    datHireDate = Convert.ToDateTime_
objDataSet.Tables("dtEmployees").Rows(lstEmployees.SelectedIndex)("HireDate"))

    lblSelectedDate.Text = _
objDataSet.Tables("dtEmployees").Rows(lstEmployees.SelectedIndex)("LastName")
    calHire.VisibleDate = datHireDate
    calHire.SelectedDate = datHireDate
    lblSelectedDate.Text &= " hired on " & datHireDate
  End If
End Sub
</script>

           
       
Related examples in the same category
1. Calendar selected value changed event (VB.net)
2. Assign today's date to asp calendar (VB.net)
3. Set asp calendar border (VB.net)
4. Calendar Control: day name format, first day of week (VB.net)
5. Calendar Control: nextprevformat (VB.net)
6. Calendar Control: titleformat (VB.net)
7. Controlling the Appearance of Individual Cells of Dates (VB.net)
8. Calendar control: on day render (VB.net)
9. Formatting Date Sections in a Calendar Control (VB.net)
10. Date Selection event in a Calendar Control (VB.net)
11. Formatting the Header Styles in a Calendar Control (VB.net)
12. On visible month changed event for a calendar control (VB.net)
13. Setting Custom Previous and Next Month Text in the Calendar Control (VB.net)
14. Reading Selected Dates in a Date Range through the Calendar Control (VB.net)
15. Allowing the Selection of Multiple Dates in a Calendar Control (VB.net)
16. Displaying a Date in the Calendar Control (VB.net)
17. Displaying a Selected Range of Dates in the Calendar Control (VB.net)
18. Basic Calendar Control: show grid lines, show day header (VB.net)
19. On Date and Month Selection Changed (VB.net)
20. Select a week (VB.net)
21. Convert selected date from asp:Calendar to long string (VB.net)
22. Selected value change envent for asp:Calendar (VB.net)
23. Get selected date from asp:Calendar (VB.net)
24. Calendar with TodayDayStyle, SelectorStyle, NextPrevStyle, and SelectedDayStyle (C#)
25. Calendar control in code behind (C#)
26. Load event in calendar selection event (C#)
27. Define and use calendar in code behind (C#)
w_ww_.j___a_v_a___2_s_.c__om__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.