ASP.NET 2.0 Page_Load is not a god
Page_Load event is not everything. Use the right page events instead of totaling depending on Page_Load and then blame ASP.NET 2.0 for not being capable J
Giving you an example:
MasterPage
è Default.aspx
o MultiView
§ View1
· uclBanking
· uclInsurance
§ View2
· uclInsurance
1st user control
No | Bank Name | Account Number | Total |
… | … | … | … |
2nd user control
No | Insurance | Insurance ID | Total |
… | … | … | … |
Here is business logic.
1. Add a new record into 1st user control
No | Bank Name | Account Number | Total |
1 | SgDotNet | 123-123-1213 | RM90.00 |
2. If that new record total is < RM 100.00 it will not populate the total into the 2nd user control.
3. Now add another new record into the 1st user control
No | Bank Name | Account Number | Total |
1 | SgDotNet | 123-123-1213 | RM90.00 |
2 | MIND | 321-333-3333 | RM150.00 |
4. By doing this, the value of RM 150.00 will be stored into the 2nd user control GridView. But since you are in the same form you will not see the changes on the fly.
5. Then how? Most people will click on View2 and back to View1 to see the changes. That is not very good.
6. Don’t cry. Uncle PreRender to the rescue.
7. Assuming previously you will check for latest GridView’s DataBind for your 2nd user control Page_Load like this:
protected void Page_Load(object sender, EventArgs e)
{
InvalidateView();
}
8. Change it to this:
protected void Page_PreRender(object sender, EventArgs e)
{
InvalidateView();
}
9. Now give it a try and you see instantaneous updates.
Well I will recommend each of the ASP.NET 2.0 developer to use the right page event. To get started, search in msn live for ASP.NET 2.0 Page Lifecycle. It looks complex but it will come in handy in development.