complete novice at work (who is also ill and feeling particularly thick)
I have the following code that gives me a generic “tool tip text” for each heading in a gridview….great.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
foreach (TableCell cell in e.Row.Cells)
{
foreach (System.Web.UI.Control ctl in cell.Controls)
{
if (ctl.GetType().ToString().Contains("DataControlLinkButton"))
{
cell.Attributes.Add(
"title", "tooltip text for " + ((LinkButton)ctl).Text);
}
}
}
}
}
What is not so great is that I obviously don’t want all of the cells to return the same generic ‘ tooltip text for’.
How would a simpleton like me adapt the code so that for the ProductID heading cell the tt says “a unique product reference”, for a Product Description heading cell the tt returns “description of the the product”.
Apologies for the dim question.
If I understand correctly, you want the tooltip to be set corresponding to the column title ?
You could do something like this :
where
headerTooltipsis a dictionary defined before :