Accessing SQL Server from a usercontrol

  • Thread starter Thread starter Sammy
  • Start date Start date
S

Sammy

When a user control access SQL Server, what happens if I host it multiple
times on one webpage (create several instances of that user control), in
terms of trips being made to the server? How can I make sure a page calls
the server only once, and gets all information required by all user
controls? This applies to a case where user controls are not even the same,
that is, multiple user controls that each access the database using a
different SQL statement/etc.

Thank you,
Sammy
 
The Page_Load of your aspx page should execute before the Page_Load of any
of your usercontrols. I would think that you can do your database work
there, populate some objects, and then pass those to the UserControls to
update them.

Just make sure to create some properties (which accept the object) or
methods (which accept the object or individual params) in your UserControl,
and have them call a UserControl-internal Render () method that updates the
UC's UI.

/// M
 

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

Back
Top