Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 371299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:06:04+00:00 2026-05-12T14:06:04+00:00

Can you have a look at the code below and tell me how I

  • 0

Can you have a look at the code below and tell me how I can fix this. Each time the day is rendered in the calendar, it calls a webservice (service.EventGetList(“ALL”)
). Its causing the page to very slow. How can I call the webservice only once, and still achieve the same results?

Protected Sub calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles calendar1.DayRender

        WordFoundAt = -1    'not found

        'declare a new dataset
        Dim ds As New DataSet("MyDataSet")

        'declare a new datatable 
        Dim dTable As New DataTable("EventsData")

        'decalre a new datarow
        Dim dr As DataRow

        'assign all events from the webservice
        openEvents = service.EventGetList("ALL")

        'build the columns for the datatable
        dTable.Columns.Add("Id", GetType(String))
        dTable.Columns.Add("Title", GetType(String))
        dTable.Columns.Add("EventStart", GetType(DateTime))
        dTable.Columns.Add("EventEnd", GetType(DateTime))


        Dim dr1 As DataRow()

        ' ds.Tables.Add(dTable)
        Dim i As Integer = 0
        For Each currEvent In openEvents

            'assign local variables to the properties of the events in the array
            id1 = openEvents(i).id
            Title = openEvents(i).Title
            eventStart = openEvents(i).EventStart
            eventEnd = openEvents(i).EventEnd


            dr = dTable.NewRow()

            dr.Item("Id") = id1
            dr.Item("Title") = Title
            dr.Item("EventStart") = eventStart
            dr.Item("EventEnd") = eventEnd


            dTable.Rows.Add(dr)

            i = i + 1

        Next

        'do a select on the datatable and filter the results to give you the events for the day of the cell 
        ' as this method gets executed every time the cell is created, the calender control creates the cells 1 x1

        dr1 = dTable.Select(String.Format("EventStart >= #{0}# AND EventStart < #{1}#", e.Day.Date.ToLongDateString(), e.Day.Date.AddDays(1).ToLongDateString()))

        'local counter variables
        Dim x As Integer = 0
        Dim y As Integer = 0
        Dim a As String

        'loop to add all available event dates to an array
        For Each dr In dr1
            datearray(y) = dr.Item("EventStart")
            idarray(y) = dr.Item("Id")
            y = y + 1
        Next

        'delcare variables for flag true/false

        'loop 
        For Each dr In dr1

            'pull event date from previous array and assign it to local variable
            a = datearray.GetValue(x)

            'assign current event date to local variable WordToFind
            WordToFind = dr.Item("EventStart")


            ' test if the current event date = what ever is in the array of events and the flag is false

            If WordToFind = a Then

                'if the cell has a control on it (i.e the Image of the X) 
                If Not e.Cell.Controls.Count > 1 Then


                    e.Cell.CssClass = "event"



                Else


                End If

            End If

            x = x + 1

        Next

    End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:06:04+00:00Added an answer on May 12, 2026 at 2:06 pm

    The event you are using is called DayRender it happens when each Day is rendered. I am also not quite sure what your web service is doing, but if you don’t want it called each time. Move the call outside of the event and store it as a local field. You can do it on Page_Init to have it be called before you controls are rendered.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies if this was already asked but, I have had a look and can't
I have big problem. Lets look on the code below: protected void Application_AuthenticateRequest(object sender,
Ok I am still having some issues with this code below. I have received
Let's look at an example - books. A book can have 1..n authors. An
I have to look into solutions for providing a MySQL database that can handle
I would like to have a QMainWindow that can change it's look at runtime,
I have a class Person which can have several Homes, each one with one
I have a variable in code that can have file path or url as
I have a issue when I look up a user name using the code
Have a look at the XAML below. I want the «HelloText» TextBlock to glow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.