|
-
Dec 3rd, 2007, 10:29 AM
#1
Thread Starter
Addicted Member
Using one Sqldatasource 4 multiple pages!
what's the best way to bind multiple controls from different sections in the website to a single datasource ?
I'm also using masterpage , I thought I could add one there and use it all over , but that didin't work.
Need your help . .
Thank you
-
Dec 3rd, 2007, 12:12 PM
#2
Re: Using one Sqldatasource 4 multiple pages!
With ASP.NET, any object you add to a page is local to that page. You'll most likely have to copy the data source itself to each page and use it accordingly, which is a better practice. This way, you actually have control over each page individually.
Possibly the best practice would be to use ADO.NET and call a stored procedure in the database, avoiding data sources altogether. They're a good learning tool, but once you hit a certain point, they become unmaintainable. I'm now using stored procs for just about every database interaction I make. Very clean, and easy to maintain.
-
Dec 3rd, 2007, 01:54 PM
#3
Thread Starter
Addicted Member
Re: Using one Sqldatasource 4 multiple pages!
What about ObjectDataSource , I can use one and bind to it whatever controls too right?
-
Dec 3rd, 2007, 03:42 PM
#4
Re: Using one Sqldatasource 4 multiple pages!
I don't think you're understanding me. When it comes to ASP.NET, you can effectively think of every page as an individual application. Each has its' own set of events, controls, and variables. There are ways of transferring information between pages, but they aren't always 100% reliable. Your best bet as an ASP.NET beginner is to use a separate data source per page. You have better control over what happens, and it's cleaner in general.
-
Dec 5th, 2007, 11:41 AM
#5
Re: Using one Sqldatasource 4 multiple pages!
http://www.vbforums.com/showthread.php?t=466658
That aside, don't treat web applications as you would a windows application. The process pipeline works differently.
-
Dec 6th, 2007, 07:36 PM
#6
Addicted Member
Re: Using one Sqldatasource 4 multiple pages!
You can however use the findcontrol() method to find the sqldatasource on different pages.
Code:
dim ds as SqlDataSource = ctype(Page.Master.Findcontrol("SqlDataSource1"), SqlDataSource)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|