DataGrid Itemcreated Problem!

  • Thread starter Thread starter Lars Netzel
  • Start date Start date
L

Lars Netzel

How come that if you have a simple page with a data grid and a button.

When you load the first time (coming to the page first time) events happens
in this order:

1. Page_Load() (including a call to bind the grid)
2. Grid_itemCreated()

But if you press the Button (that ttriggers a postback) they happen in this
order?
1. Grid_ItemCreated()
2. Page_Load
3. Grid_ItemCreated()
4. Button_Click()

WHY WHY WHY... does the Item_Created happen before Page Load on a
postback... What triggers that????

Best Regards/
Lars Netzel
 
Hello Lars,

Just a guess here...

Controls are repopulated from ViewState somewhere between OnInit and OnLoad.
So, your grid is getting recreated twice.

You could try wrapping the call in OnLoad with if (!Page.IsPostBack).
 
Back
Top