Css – How to add tooltip for Commandfield ButtonType as image

asp.net, css

I have to add tooltip for my gridview edit image button. I coded as Commandfield.

<asp:CommandField ButtonType="Image"      HeaderStyle-HorizontalAlign="center"    EditText="Edit" UpdateText="Edit"     ShowEditButton="True"      ItemStyle-VerticalAlign="Top"    EditImageUrl="~/Images/edit.png"        UpdateImageUrl ="~/Images/Save.png" CancelImageUrl ="~/Images/cancel.png"     ItemStyle-Width="15px" ControlStyle-Width="15px"></asp:CommandField>

Is it possible to add a tooltip in gridview commandfield button type as image?

Best Solution

Following code works well:

protected void gvResourceEditor_RowDataBound(object sender, GridViewRowEventArgs e)        {            try            {                if (e.Row.RowType == DataControlRowType.DataRow)                {                    e.Row.Cells[4].ToolTip = "Edit Resource Details";                    if (e.Row.RowState == DataControlRowState.Edit || e.Row.RowState.ToString() == "Alternate, Edit")                    {                        int i = 0;                        foreach (TableCell cell in e.Row.Cells)                        {                            if (e.Row.Cells.GetCellIndex(cell) == 4)                            {                                ((System.Web.UI.WebControls.ImageButton)(e.Row.Cells[4].Controls[0])).ToolTip = "Update Resource Details";                                ((System.Web.UI.LiteralControl)(e.Row.Cells[4].Controls[1])).Text = "&nbsp;";                                ((System.Web.UI.WebControls.ImageButton)(e.Row.Cells[4].Controls[2])).ToolTip = "Close Resource Details";                            }                            i++;                        }                    }                }            }            catch (Exception _e)            {            }        }