J
JV
I thought I'd done it all with DataGrids, but I hit a situation I haven't
seen anyone cope with. This might make a great article.
The problem with the template columns in a datagrid is that the actual id of
the controls in the template are not generated until the page is rendered,
which means there is not really an event that you can hook in order to do
something that requires the actual control id as rendered.
The case I had was for ADA compliance. Certain rows in this particular
datagrid were generating dropdownlists, and for those rows it was necessary
to wrap text from a different column in a <label> control and set the "for"
attribute to the ID of the dropdownlist. However, the ItemDataBound event
was not sufficient for this because it was not yet possible to determine the
ID of the control as it would be rendered. For example, in the item
template, the ID of the DropDownList is "foreign_key", but you can't set up
<label for="foreign_key"> because it will render with an ID reflecting the
name of the datagrid, and a sequence number (example:
id="dgLookupInput__ctl4_foreign_key").
The only solution I can think of for this involves client-side scripting.
If I am correct about this, it seems like a pretty big oversight in the
DataGrid. I have not yet investigated Whidbey, but I hope the new grid
allows for such things.
seen anyone cope with. This might make a great article.
The problem with the template columns in a datagrid is that the actual id of
the controls in the template are not generated until the page is rendered,
which means there is not really an event that you can hook in order to do
something that requires the actual control id as rendered.
The case I had was for ADA compliance. Certain rows in this particular
datagrid were generating dropdownlists, and for those rows it was necessary
to wrap text from a different column in a <label> control and set the "for"
attribute to the ID of the dropdownlist. However, the ItemDataBound event
was not sufficient for this because it was not yet possible to determine the
ID of the control as it would be rendered. For example, in the item
template, the ID of the DropDownList is "foreign_key", but you can't set up
<label for="foreign_key"> because it will render with an ID reflecting the
name of the datagrid, and a sequence number (example:
id="dgLookupInput__ctl4_foreign_key").
The only solution I can think of for this involves client-side scripting.
If I am correct about this, it seems like a pretty big oversight in the
DataGrid. I have not yet investigated Whidbey, but I hope the new grid
allows for such things.