Evening all.
I have the following code that I need looking into - basically I'm clutching at straws here. I have a gridview that I would like to assign tooltips to.
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"))
{
Dictionary<String, String> headerTooltips = new Dictionary<String, String>();
headerTooltips["Product ID"] = "A unique product ID";
headerTooltips["Product Description"] = "Description of product";
String headerText = cell.Text;
cell.Attributes.Add("title", headerTooltips[headerText]);
}
}
}
}
}
Essentially what I am trying to achieve is a tool tip that appears by each column heading (i.e. Product ID and Product Description.)
However, when I use the above code, I receive the following error message "The given key was not present in the dictionary." This appears on the
cell.Attributes.Add("title", headerTooltips[headerText]);
line.
Can someone point out the error in my ways? Thank you for any help or suggestions.