K
Kubuli John
It appears that there are only 2 ways to get to a particular control
in a DataGrid - either use the FindControl method or try to work your
way through the (apparently undocumented) hierarchy of controls
(dgItem.Controls[0].Controls[0].Controls[2]...).
Using FindControl is OK except that to make generic sort buttons in
the headers of template columns, I have to add LinkButtons. If I use
FindControl to get to these controls (to enable or disable them when
switching between view and edit modes), they each have to have a
unique name. This means that I have to hard-code the control id's
into my code, making it difficult to reuse the code when I change what
the grid is displaying. Ditto for the images since I have to hide all
other images when I show one.
I was hoping to be able to iterate through all of the controls in the
header row looking for LinkButtons called "btnSort", but I do not want
to try to decipher the hierarchy of controls to use
dgItem.Controls[0].Controls[1]... It doesn't look like there is a
single Controls collection that goes through all of the control
hierarchy either.
The Columns collection is no use either since it only gives me access
to the generic header style items, not my custom header controls.
Is there a documented hierarchy that I can rely on to locate the
appropriate control, or some other way to navigate through a DataGrid
or DataGridItem?
Thanks,
John H.
in a DataGrid - either use the FindControl method or try to work your
way through the (apparently undocumented) hierarchy of controls
(dgItem.Controls[0].Controls[0].Controls[2]...).
Using FindControl is OK except that to make generic sort buttons in
the headers of template columns, I have to add LinkButtons. If I use
FindControl to get to these controls (to enable or disable them when
switching between view and edit modes), they each have to have a
unique name. This means that I have to hard-code the control id's
into my code, making it difficult to reuse the code when I change what
the grid is displaying. Ditto for the images since I have to hide all
other images when I show one.
I was hoping to be able to iterate through all of the controls in the
header row looking for LinkButtons called "btnSort", but I do not want
to try to decipher the hierarchy of controls to use
dgItem.Controls[0].Controls[1]... It doesn't look like there is a
single Controls collection that goes through all of the control
hierarchy either.
The Columns collection is no use either since it only gives me access
to the generic header style items, not my custom header controls.
Is there a documented hierarchy that I can rely on to locate the
appropriate control, or some other way to navigate through a DataGrid
or DataGridItem?
Thanks,
John H.