views:

118

answers:

1

Hello all

Trying a different approach for tooltipping on a gridview using the following code:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {

            { 
                if (e.Row.RowType == DataControlRowType.Header) 
                    { 
                        foreach (TableCell cell in e.Row.Cells) 
                            { 
                                foreach (Control ctl in cell.Controls) 
                                    { 
                                        if (ctl.GetType().ToString().Contains("DataControlLinkButton")) 
                                            { 
                                                cell.Attributes.Add("title", "tooltip text for " + ((LinkButton)ctl).Text);

                                            } 

                                    } 
                            } 
                    } 
            }

        }

How would I go about manipulating this code so that the first column tooltip says " presents the category description", the second column says "represents the total percentage", etc, etc.

I'm not sure how would go about achieving different tooltip text for each column - would I implement an index or add in another loop? I'm not sure where to go from here...apologies for being thick.

A: 

Why don't you use the

ToolTip='<%# Eval("ColumnName")%>'

in the itemtemplate when you bind the Text property also bind the tooltip property as well(in aspx file).

Hope that will help

Asim Sajjad