DataList <td onMouseOver>

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
 
R

Ryan Moore

No, it doesn't seem like you can access the e.Cells from the OnItemCreated
event.

any other ideas?
 
W

Weston Weems

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
 
E

Eliyahu Goldin

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
 
R

Ryan Moore

Yes, but the ItemTemplates ARE placed into TableCells... is there no way to
add an attribute to those cells?
 
E

Eliyahu Goldin

Try e.Item.Attributes["onmouseover"] = ...

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

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top