How to create an asp.net calendar link to database?
We are trying to implement a calendar in an asp.net page and link it a database. The calendar should highlights dates based on data in the database tables similar t开发者_运维百科o airline ticket booking calendar.
Thank you
No one is going to write an application for you here... If you have a specific question you should ask it. Without that here is my best advice.
Start by looking at how to implement asp.net's calendar control:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.calendar%28v=vs.80%29.aspx
Then look at using ADO.NET to communicate from your web app to your db. Here is a good place to start:
http://msdn.microsoft.com/en-us/library/e80y5yhx.aspx
A calendar has a property SelectedDates which is a list of the dates that have been selected. All you need to do if you get a list of dates from a database is add them to the property SelectedDates.
For example:
Public Sub Calendar_Prerender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar.PreRender
Dim tomorrow As DateTime = Now.AddDays(1)
Dim nextday As DateTime = Now.AddDays(2)
Calendar.SelectedDates.Add(tomorrow)
Calendar.SelectedDates.Add(nextday)
End Sub
The calendar loads with tomorrow and the day after selected.
精彩评论