Mouseover, mouseout, click etc on datagrid.

J

johnnydublin

Hi there,
Does anyone know of a way that I can specify javascript functions that
are to be run when a cell is clicked, mouse over etc in a datagrid
without attaching the function to every single cell?

I have a diary view with resources across the top and times down the X
axis which means it contains hundreds of cells. I want to add some nice
javascipt that makes the cells change colour as the mouse moves over
them etc. I can get it to work fine by putting a function call behind
each cell (added during the itemdatabound event) but it makes for a
very big download and a lot of processing at data itemdatabound time.
Can I specify that if any TD is clicked I want to run a function?
Any help would be much appreciated,
Thanks
Johnny
 
S

S.M. Altaf [MVP]

Hi Johnny,

Handle the ItemDataBound event for the datagrid. In each of the rows of type
Item or AlternateItem, look for the cell you want.
Perform an .Attributes.Add() for the cell, and in this method you can
specify the javascript function you want to call. For example (I'm typing
this off my head, I don't have the IDE open)

e.Item(4).Cells(0).Attributes.Add("onMouseOver","myColoringFunction();")

HTH
Altaf
 

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,054
Latest member
TrimKetoBoost

Latest Threads

Top