|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Display data in asp:CalendarI 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 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 Show quoteHide quote "phoebe" wrote: > 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 > > > DWS, thanks for your ideas, i manage to solve it.
Show quoteHide quote "DWS" <D**@discussions.microsoft.com> wrote in message news:DA316A8C-8A15-4071-B337-5043214B228F@microsoft.com... > 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 > > > "phoebe" wrote: > >> 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 >> >> >>
Trouble with validator control ? Script not found
ObjectDataSource, GridView and ItemTemplate NullReferenceException With Different Register Directive Is there a free .GIF software? Trouble with validator control ? script not found ASP.NET 2.0 DataView DetailsView ImageField displaying images from Filtering the Asp:FileUpload control Asp.Net 2.0 Bug Adding AutoPostBack to a webcontrol Changing RadioButton's NAme and ID properties using vb.net |
|||||||||||||||||||||||