DataList <td onMouseOver>

  • Thread starter Thread starter Ryan Moore
  • Start date Start date
R

Ryan Moore

I am trying to modify the onMouseOver attribute of a <td> cell created by a
DataList... according to

http://msdn.microsoft.com/library/d...fsystemwebuiwebcontrolsdatagridclasstopic.asp


"You can control the appearance of the DataGrid control by programmatically
adding attributes to the <td> and <tr> tags rendered by the control on the
browser. Attributes can be programmatically added by providing code in the
event handler for the OnItemCreated or OnItemDataBound event.
To add an attribute to the <td> tag, first get the TableCell object that
represents the cell in the DataGrid control you want to add the attribute
to. The Control.Controls collection for the Item property of the
DataGridItemEventArgs object passed into the event handler can be used to
get the desired TableCell object. You can then use the
AttributeCollection.Add method of the Attributes collection for the
TableCell object to add attributes to the <td> tag."


For the life of me, I cannot get the TableCell object that this page refers
to, can someone shed some light for me?
thnx
 
No, it doesn't seem like you can access the e.Cells from the OnItemCreated
event.

any other ideas?
 
In the OnItemCreated event of the datalist, you should be
able to reference e.Cells which through that heirarchy
should let you get a specific tablecell.

Also keep in mind, it looks like that article is speaking
about the datagrid specifically. I know some of the
lightweight record rending controls dont have all the same
events, or even the ability to acces e.DataItem from
databound/itemcreated events.

Weston Weems
 
DataList is not made out of cells. DataGrid is. DataList items are defined
in ItemTemplate. You can navigate within DataListItem only if you know what
is in your ItemTemplate.

Eliyahu
 
Yes, but the ItemTemplates ARE placed into TableCells... is there no way to
add an attribute to those cells?
 
Try e.Item.Attributes["onmouseover"] = ...

Probably e.Item is the td you mean. Even if is it not, it should support
onmouseover event.

Eliyahu
 
Back
Top