DataGrid Itemcreated Problem!

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
 
M

Matt Berther

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top