automatic databinding?

D

Davids

I have an AccessDataSource control and a DataList control and databinding to
display the database results. Although there is no Page.DataBind() in my
codebehind code it obviously is there somewhere, do the controls do it or is
it by default done in the page building sequence?
How can I control my self if that particular control is to be databound or
not?
 
J

Johann MacDonagh

The DataSource controls provide the necessary logic to bind your controls on
each page load. If you want more control, wire up the Selecting event. This
event allows you to specify whether you want the DataSource control to bind
data or not on that particular page load. Here's an example:

Sub AccessDataSource1_Selecting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)
If DateTime.Now.DayOfWeek = DayOfWeek.Monday Then
e.Cancel = True
End If
End Sub

In this example, the AccessDataSource control named AccessDataSource1 will
only bind the data if it's Tuesday-Sunday.

Happy coding,
Johann MacDonagh
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top