views:

66

answers:

2

Is it possible to add a java script mouse over to a grid control cell? If so, how do you do it?

Specifically, we're trying to show a different tool tip for each cell, not the entire column or row.

+1  A: 

Yes it's possible. At your grid's RowDataBound, try to add your javascript using Row.Cells :

  void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)
  {
    if(e.Row.RowType == DataControlRowType.DataRow)
    {
        //e.Row.Cells[1].Attributes["onmouseover"];
    }
  }
Canavar
How do I pass in the JS function to call?
stringo0
e.Row.Cells[1].Attributes["onmouseover"] = "javascript:YourFunction();"You will have to figure out how to pass the function your cell info for it to work.... Don't know how you have your JS setup....
klabranche
+2  A: 

You should be able to add the tooltip to each cell / column like so:

gridview.rows(x).cells(y).ToolTip="blah"

or say in the RowDataBound event...

e.Row.Cells(x).ToolTip="blah"

klabranche
Do the data cells already have a tooltip like functionality?
stringo0
Yes. It's baked in. :)
klabranche
This is the easiest solution for our scenario.
stringo0
Glad to help. :)
klabranche