Display data in asp:Calendar

P

phoebe

Hi, Good Day!

I had a tableholiday that store startdate, enddate and holiday name.

Below is the coding to display the holiday name in asp:Calendar webcontrol
when a page is load. It manage to display a holiday which is only 1 day.

I need more as if the holiday are 2 or 3 days, how should i display it on
the calendar as my database store only the startdate and enddate for the
holiday.

Please help. Thanks in advanced.

rgds,
phoebe.


Sub cal_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs)
Dim objDb As New SqlConnection(myConnectionString)

Dim objCom As New SqlCommand("select * from holiday where date1=@sdate",
objDb)

objCom.Parameters.Add("@sdate", e.Day.Date)

objDb.Open()

Dim objDr As SqlDataReader = objCom.ExecuteReader()

Do While objDr.Read()

e.Cell.Controls.Add(New LiteralControl("<br />" &
String.Format(objDr.GetString(0))))

Loop

objDb.Close()



End Sub
 
D

DWS

phoebe,

Two ideas
1. Make an entry in the database for each day of the holiday. five day
holiday=five entries in database.
2. Change the sql to search for the date or a date range (I'm guessing date2
is the end date of the holiday)
select * from holiday where @sdate = date1 or @sdate > date1 and @sdate <=
date2

Finally you should move your sql connection and command to the calendar
prerender event that way it will be executed only once verus for every day.

Good Luck
DWS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top