Controling Datasources

B

barryfz

I am working with the new datasource component which I guess is a
replacement for the dataadapter/dataset cmoponents. I guess it is cool that
I can hook these up without writing any code behind now (does anybody in
asp.net use the vs studio gui for anything but a notepad substititue, all i
see in post after post is a lot of asp code, i thought the idea of vs.net
was to eliminate the need for coding this stuff, but that is another rant).
Anyway I get data and I bind it to different things, I can hook parameters
to various things. All very cool. But how do I control these things. They
always load data. I don't necessarily want them to load data all the time.
I may have user controls or panels that are not visible/enabled at times and
I don't need the data loaded for them. There doesn't seems to ben an
enable/disable structure.

How do I stop them from loading when I don't need the data? Am I supposed
to code many look alike pages now that only have datasources that all need
to be loaded? I seem to be missing something here.
 
W

Walter Wang [MSFT]

Hi Barry,

Thank you for your post.

Based on my research, use SqlDataSource for example, will not load data if
the binding control is hidden. You can verify this by following test:

1) Create a webform, add a SqlDataSource and a GridView, bind the GridView
to the SqlDataSource
2) Create an event handler for SqlDataSource's Selecting event, this event
is triggered before the DataSource control is about to call the Select
method to retrieve data;
3) If you set GridView.Visible = false, you will notice that the Selecting
event of SqlDataSource doesn't gets fired.

This behavior can prove that the SqlDataSource's data loading is controlled
by the binding control, since a control doesn't get rendered when it's
hidden, so the data doesn't need to load.

As for the Enable property, because the data still needs to rendered, so
the DataSource will still need to load the data.

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

Walter Wang [MSFT]

Hi Barry,

Thank you for your update.

If you have any other questions or concerns, please do not hesitate to
contact us. It is always our pleasure to be of assistance.

Have a nice day!

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top