Strange Behavior with saving/reloading view

Topics: Web Client Software Factory
Jul 5, 2007 at 7:21 PM
I'm having some strange behavior happening.

I am using WCSF with a view presenter for the the following.

I have a ui that has a grid in on part of it and the add functionality just below it. When the add button is clicked, the insert does fire. Once that is done and the page then reloads, I am making a call to get the data again and place it into the view which is then utilized in the objectcontainerdatasource for the grid. Seem pretty basic.

The problem is that the data doesn't appear on sql server express until after the page finishes loading. So the data in the grid does not have the newly added record. I receive no errors on insert and I can see the data get to the db but the call to get the data doesn't return the full set of data. Only what was previously loaded. I verified that the collection that is being utilized doesn't have the new data when it is called but yet when I check the db and then refresh the whole page, I then am able to see the new record in the grid.

It almost appears that there is a delay of some time in the processing for when the data is inserted and when it is available.

Any thoughts on what might be happening? I'm kinda stumped at this point....

Thanks.
Jul 5, 2007 at 7:56 PM
I did a bit further digging and it appears that the view presenter is firing twice. The first time in when calling an insert, it inserts the record and then on page load, it reloads the view but without the new record...it then proceeds to fire off the base page load on the master page and then somehow ends up firing the button click event of the insert again! But this time without a page load so the data never refreshes! What is the world is going on? I'm totally lost as to how this could be happening!

Any ideas?
Jul 5, 2007 at 10:11 PM
I think I got it solved.

In the pageload, the code would perform this.presenter.OnViewLoaded();

I moved that call to the Page_LoadComplete just prior to the DataBind. Seems to work as it should now.

If there is another way to solve this, I am open to it. Correct me if I'm wrong.

Thanks.
Pat.
Jul 6, 2007 at 1:04 AM
Pat,

Regarding the double insert firing, is your insert button inside a formview or detailview and has the Insert CommandName?.

On view refreshing issue, I think the presenter is supposed to set the new info on the view after it processes the OnInsert call.
Jul 6, 2007 at 2:11 PM
Yes, the insert that is firing is inside a formview and has the Insert command name.

I'll have to debug further to find out about the OnInsert and view refreshing...


FreddyRios wrote:
Pat,

Regarding the double insert firing, is your insert button inside a formview or detailview and has the Insert CommandName?.

On view refreshing issue, I think the presenter is supposed to set the new info on the view after it processes the OnInsert call.

Jul 6, 2007 at 2:34 PM
I changed the calls that I had listed as Insert to OnInsert and changed the underlying layers to be called something other than Insert, the double firing of insert stopped. Seems I was adding in some reserved functionality by calling the insert Insert. As for the refresh, I still have to put it in the Pageloadcomplete instead of leaving it in the PageLoad (as per the view-presenter that is generated by wcsf). Don't know why though...


plstovall wrote:
Yes, the insert that is firing is inside a formview and has the Insert command name.

I'll have to debug further to find out about the OnInsert and view refreshing...


FreddyRios wrote:
Pat,

Regarding the double insert firing, is your insert button inside a formview or detailview and has the Insert CommandName?.

On view refreshing issue, I think the presenter is supposed to set the new info on the view after it processes the OnInsert call.