Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

postback is confusing me

Status
Not open for further replies.

stucker79

Technical User
Dec 7, 2004
25
US
I am using a control I purchased called calendar.net. I have some code in my page load event that populates that calendar with items. I currently have the code in an if not ispostback statement. I realize now that when a user navigates away from the page and then goes back to it, that code fires again. This is causing my calendar to get populated again. What is the best way to ensure my calendar doesn't repopulate?
 
I forgot to mention that when I debug this, it almost seems to be cached somehow. I say this because when I stop and restart the project, it will show up with duplicate entries on first page load.
 
Do you put the data into a database or something on each visit? Does the control have built-in caching features?

If not, please post the code block where the calendar gets populated and we can take a look.
 
I'm not sure if the control has built in caching, i looked in there help file and couldn't find anything. Here's my code:

If Not IsPostBack Then

SqlConn.ConnectionString = ConfigurationSettings.AppSettings("SqlConn")

'Populate Calendar

Dim daGetTitle As SqlDataAdapter = New SqlDataAdapter
Dim cmdGetTitle As SqlCommand = New SqlCommand
cmdGetTitle.Connection = SqlConn
daGetTitle.SelectCommand = cmdGetTitle
cmdGetTitle.CommandType = CommandType.StoredProcedure
cmdGetTitle.CommandText = "spGetTitle"

DataCmp.daCourse.Fill(DataCmp.DsTraining, "Course")
DataCmp.daCourseTopic.Fill(DataCmp.DsTraining, "CourseTopic")
daGetTitle.Fill(DataCmp.DsTraining, "spGetTitle")
DataCmp.daInstructor.Fill(DataCmp.DsTraining, "Instructor")
DataCmp.daLocation.Fill(DataCmp.DsTraining, "Location")
DataCmp.daCourseInstance.Fill(DataCmp.DsTraining, "CourseInstance")

CalendarCtrl.DataSource = DataCmp.DsTraining
CalendarCtrl.DataMember = "spGetTitle"

CalendarCtrl.DataBind()

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top