Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datagrid and itemCreated

Status
Not open for further replies.

cjburkha

Programmer
Jul 30, 2004
76
US
Hi all

If I wire up itemCreated and insert this code:
If e.Item.ItemType = ListItemType.Footer Then
Response.Write("got the footer!")
end if

I get "got the footer" written to my page 3 times. Does anyone know why this would be?
 
I have 5 visible collums, and 7 total.

I'm not sure about records, it seems to happen no matter how many records I have, but it ranges on these pages from 2-8.
 
Try stepping though your code - it will give you an indication of why it happens (i.e. is it there there are several items that all have a listitemtype of footer.)

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Try stepping though your code - it will give you an indication of why it happens (i.e. is it there there are several items that all have a listitemtype of footer.)

I have, and I don't think I fully understand what all happens in building a datagrid.

Here is msdn
The ItemCreated event is raised when an item in the DataGrid control is created, both during round-trips and at the time data is bound to the control.

So my understanding is that when a row is created, itemCreated will fire, and when the data is bound to the row, itemCreated will fire. That explains two, not three.

Specifically,
are several items that all have a listitemtype of footer
No, there is only one footer in this datagrid. I do have template collums with editItemTemplate specified, so maybe it fires once for normal colums which use the datagrid footer, once for templatecollums looking for a specific footer, and once for databinding. I'll try and test for that.

That doesn't make perfect sense though, because it should fire twice for normal columns (round trip and data binding) and twice for template columns (round trip and data binding)

Thanks for your help guys,

CJB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top