0
votes

I have a gridview for which I am binding data from a Generic List collection. Currently not connected to DB. All the columns in the GridView are defined as properties(get;set.

I want to have tooltip on one of the columns. The column has a very big description. I want to show only 3 words in the column and the rest of the description should appear in tooltip.

Currently my gridview has only asp:gridview id and runat server

There are no columns, headertemplate and itemtemplate.

Could anyone suggest some idea on this.

Thanks in advance

2
do you have it on autogeneratecolumns or have you hard-coded your columns in?Jason

2 Answers

0
votes

Well, I don't know how you are getting your columns in place...but I suppose you could put a Label webcontrol in the itemtemplate for the header of each column, and give that label's tooltip property the value you want it to have.

Seems to me like that would be a pretty viable solution for this, if I'm understanding you correctly..

0
votes

You can use an itme template with a label as mentioned. Bind the label the full description:

<ItemTemplate>
   <asp:Label id="l1" runat="server" Text='<%# Eval("Description")' />
</ItemTemplate>

In code-behind, use RowDataBound to process each row accordingly:

protected void RowDB(..)
{
   Label l = e.Row.Cells[4].Controls[1] as Label;
   if (l == null) return;

   string description = l.Text;
   l.Text = //Partial text here
}

And the grid will bind each row, the full text is passed to a variable, and you can insert a substring of the text (3 words or such) by assigning the new value to the text property.

What kind of tooltip are you looking for? You could use the tooltip property, or consider using the ACT HoverMenuExtender: http://www.asp.net/AJAX/AjaxControlToolkit/Samples/HoverMenu/HoverMenu.aspx