Button Click after Page Load?
Posted on 2011-09-12
It's kind of a general question because I'm an ASP.NET noob (I come from Winforms).
I've got a page with a datagrid and a button. And this datagrid is databound to a collection. When the button is clicked I add an object to the collection in the click event. But the click event is handled after the load event of the page. So the added object is not immediatly visible in my databound datagrid.
To solve this I ask in the page load if the button was the control that caused the post back. If so, I add the object to the collection and rebind the collection to the datagrid.
It seems to me that this is not the way to go. Because I'll have to ask for every button on the page if it caused the post back if I want stuff to display immediatly on the page.
So help an ASP.NET noob out guys. How are webdevelopers supposed to implement the aformentioned setup?