Hi Monty,
Well, I have just found out it's a known issue of ASP.NET 2.0, we have an
open bug record for it.
Some explanation of this issue:
When ClientID is called, part of the operation is to retrieve the naming
container prefix to return the full client ID (with naming container
prefix), through the calling of UniqueID property. At the time ItemCreated
event is called, the control created in the event has not been added to the
control tree. It is added to the control tree after the event is done in
DataGrid's code. So you observed that ClientID returns only the ID in
ItemCreated event.
In v1.x, the UniqueID is computed everytime the property is called, meaning
that the control would walk up the tree to gather the necessary id prefix
for the naming containers. In v2.0, for better performance, we introduced
some caching code so the control tree walk up would only be done once for
the first time it is being accessed.
As a workaround, we should avoid calling ClientID in ItemCreated event.
If this workaround doesn't work for you, please contact our Customer
Support and Service to see if there will be hotfix available before it's
fully fixed in future versions. We're sorry for the inconvenience caused.
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Monty - 07 Dec 2007 03:44 GMT
Hi Walter,
Thanks for the research. Do you have KB number for this? Do you know if this
issue is resolved with v3.5?
Thanks again...
Monty - 09 Dec 2007 15:20 GMT
For anyone following along, no this issue has not changed in the 3.5
Framework, but I was able to work around this issue by moving my code from
the ItemCreated event to the ItemDataBound event. Good luck!
Walter Wang [MSFT] - 10 Dec 2007 05:10 GMT
Hi Monty,
The public KB is under development.
Thanks for your feedback, this will certainly benefit others if they also
encouter this issue.
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.