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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.NET 2.0 Store Procedures executing multiple times per page load 3

Status
Not open for further replies.

lastdonuk

Programmer
Jan 19, 2005
58
GB
Hi,

I have a speed and general overhead issue in my web app (C#) whereby I can see a gridview datasource (a Stored Procedure) executing usually twice on every firing of any event on a page - drop down list select change, another gridview's selected index change, button click, etc.

The gridview in question is the basis for much of the subsequent data and its data can change on the change of one initial dropdown, but other than that it doesn't get used.

In fact, initially it's disabled...I tried to cache the data but I could still see the underlying stored procedure running in SQL Profiler...can you help?

lastdonuk
 
What is the datasource of the gridview? You say a stored procedure, but that is not the datasource, that is what feeds the datasource. Are you using the DataSource controls, or are you using a dataset/datatable as the datasource for the grid?
 
Hi there,

Thanks for the reply.

I'm using a standard SQLDataSource, is that what you're asking?

Thanks in advance,

Rob

lastdonuk
 
Yes that is what I am asking, and I strongly suggest you stop using those controls. They are very limiting, especially when trying to debug a problem such as this. Get your data into a datatable and bind that to your grid and see if you still have the problem. My guess it is related to the datasource control.
 
the more markup you use the less you can test/debug.
1. get rid of the datasource control
2. create a repository object to manage database access. (presentation should know nothing about databases)
3. in the repository call the stored proc using ado.net*
4. in the code behind bind the grid to results of the repository.

* data access is a solved problem. there are many libraries that do this already so directly writing ado.net objects is wasteful. libraries include NHibernate, ActiveRecord, WilsonORMapper, SubSonic, LLBL, etc. some are OSS others have a small fee.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Hi,

Thanks very much both for sharing your knowledge, I'll investigate and hopefully update you with good news...

I really appreciate your time and thoughts.

Cheers,
Bob

lastdonuk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top