Results 1 to 6 of 6

Thread: Using one Sqldatasource 4 multiple pages!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    150

    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

  2. #2
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    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.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    150

    Re: Using one Sqldatasource 4 multiple pages!

    What about ObjectDataSource , I can use one and bind to it whatever controls too right?

  4. #4
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    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.

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  6. #6
    Addicted Member mday2792's Avatar
    Join Date
    Dec 2006
    Posts
    145

    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
  •  



Click Here to Expand Forum to Full Width