T
Tumurbaatar S.
Spent 2..3 days imagining how the DataGrid works.
And found that:
1. Even the Pager position is not set to TopAndBottom, ItemCreated event
raised twice for the Pager item. So if you're using only Top or Bottom
pager,
don't forget this behavior.
2. ItemCreated is called 2 times during postback processing for every
item/row
within the DataGrid. 1st time - before Load and 2nd time - after it.
I add some controls to the Pager during ItemCreated raised before Load and
found that
these controls vanished away after Load. So I have to recreate them on
ItemCreated
called after Load.
I don't understand where they're going away after creating 1st time?
3. On 1st ItemCreated event I adjust some visual styles of the Footer
(removing some cells, changing ColSpan and etc). And (may be it follows from
2),
after Load and on 2nd ItemCreated event these changes are lost. I have to
modify them
again.
4. From 1 and 2, it follows that ItemCreated for Pager are called 4 times.
5. ItemDataBound does not raise for Pager item.
6. I've 2 DropDownList on my page. One is in the Footer and another outside
of the DataGrid.
I fill the Footer's list during ItemDataBound event and the external list -
from PageLoad with
checking of IsPostBack. So the external list is data bounded only 1 time and
it persists
its items during round trips. But the Footer's list loses its items and I
have to re-fill it
on every ItemDataBound.
EnableViewState is true for the DataGrid and anybody can explain why items
get lost?
7. Do I need to data bind above Footer list on ItemCreated or on
ItemDataBound?
If on ItemCreated, then before Load or after or on both cases?
Anything wrong in above reasoning? Something to add more or change?
And found that:
1. Even the Pager position is not set to TopAndBottom, ItemCreated event
raised twice for the Pager item. So if you're using only Top or Bottom
pager,
don't forget this behavior.
2. ItemCreated is called 2 times during postback processing for every
item/row
within the DataGrid. 1st time - before Load and 2nd time - after it.
I add some controls to the Pager during ItemCreated raised before Load and
found that
these controls vanished away after Load. So I have to recreate them on
ItemCreated
called after Load.
I don't understand where they're going away after creating 1st time?
3. On 1st ItemCreated event I adjust some visual styles of the Footer
(removing some cells, changing ColSpan and etc). And (may be it follows from
2),
after Load and on 2nd ItemCreated event these changes are lost. I have to
modify them
again.
4. From 1 and 2, it follows that ItemCreated for Pager are called 4 times.
5. ItemDataBound does not raise for Pager item.
6. I've 2 DropDownList on my page. One is in the Footer and another outside
of the DataGrid.
I fill the Footer's list during ItemDataBound event and the external list -
from PageLoad with
checking of IsPostBack. So the external list is data bounded only 1 time and
it persists
its items during round trips. But the Footer's list loses its items and I
have to re-fill it
on every ItemDataBound.
EnableViewState is true for the DataGrid and anybody can explain why items
get lost?
7. Do I need to data bind above Footer list on ItemCreated or on
ItemDataBound?
If on ItemCreated, then before Load or after or on both cases?
Anything wrong in above reasoning? Something to add more or change?