Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 8th, 2003, 10:25 AM
Registered User
 
Join Date: Dec 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Radoslav
Default Database changes made after Page_Load

Hello,

I write an application with dynamically generated buttons that make changes to a database (DELETE, INSERT). A button calls a sub (Objednavka) that makes the change (AddHandler btnItem.Command, AddressOf Objednavka). The problem is that I detect the change made by the mentioned buttons inside Page_Load sub but the change sub runs after the Page_Load, not before it so the data on the page is incorrect (one step old). I can use a workaround and refresh the page after the change is made in the db but then I loose my scrool position on the web page which needs to be retained. :(

Any help appreciated,
Radoslav

 
Old December 8th, 2003, 10:44 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Usually, anything that dynamically generates objects on the page based on some underlying data (typically utilizing databinding) is done based on events that affect that underlying data. You usually need to do this once when the page loads, but you also need to redo this when the data is changed.

I typically create a method that handles the retrieval of the data and the binding/drawing of the controls that are affected. I call this routine during the first page load (based on IsPostback), then again whenever I do something that affects the data.

Method: Page_load()
    If Not IsPostback Then
        'Call sub to build the dynamic controls
        buildMyDymanicControls()
    End If

Method: buildMyDymanicControls()
    'Get data from database
    'Manipulate controls thur databinding

Method: someButtonHandler()
    'Do things that affect the data
    'Call sub to rebuild the dynamic controls
    buildMyDymanicControls()


Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with the word processor that I made alexnichols Xcode 0 February 19th, 2008 03:44 PM
What to use for a home made notepad Apocolypse2005 Beginning VB 6 9 June 30th, 2006 11:01 AM
Page_Load not working! New2ASPnet General .NET 6 July 28th, 2004 01:53 PM
forcing a page_load ? Rashe ASP.NET 1.0 and 1.1 Basics 2 February 16th, 2004 10:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.