I have two, possibly related formatting issues with the WebGrid component:
These problems occur whether the grid is specified declaratively or via program code.
Help! I don't want top but !'m beginning to loose faith in this product...
VS2008 Pro, IG2008v1, C#
Kind regards
Paul
In that case what you can do is to store all the data you want in the session object. That way you can reconfigure your grids on every postback without having to requery the database. There might be a better solution, but this one is quick and effective :)
Thanks for your reply, it's beginning to make a bit more sense now. However, I believe there is still a gremlin lurking somewhere in the woodpile.
I response to your question regarding programmatic vs declarative creation of the controls - I've tried both. I started with declarative and encountered the problem with the second grid on the page losing its formatting on a postback. So, i though I'd try programming - it does a little better (for example some issues with styles are circumvented) but the second grid still loses its formatting on postback.
So, it still looks like a bug such that when two (or more?) grids are on the same page the second loses its viewstate on postback.
I hate having to requery the database to get round a bug like this, but at least I know what to do. (I have to requery the database because although the grid data may remain unaltered, all my grid formats: fonts, colour, border properties and so forth are stored in tables.).
Thanks again.
Are you creating the webgrids (or configurating them) programatically? If so, you should re-configure them on every postback, since those configs will not be saved in the viewstate and therefore they'll not be rendered to the next page.
Sorry, I should have made it clear I am testing for IsPostBack and only doing the databind on initial page load.
To try and isolate the problem I have ensured that no code is executed in the event:this.IsPostBack == true. The only other think I can think of that may be relevant is that the grids are on a content page. The master page contains two IG Menus.Under normal conditions, I intercept the menu clicks on the master page and and park data in a hidden control on the master page before cxausing a postback. I check the hidden control in the postback processing on the content page and take appropriate action. That all seems to be working OK.
Thanks for responding
1: are you rebinding the data on postback?
One of the things to consider is the use of is "IsNotPostback" to prevent the grid from running whatever code is in the page load.
before running other events in webgrid, like grid_dblclick, etc.. the pageload events fire first.