Tooltip not displaying in IE 8, Chrome, FF for gri

2019-08-16 04:51发布

My gridview consists of a command field with 'showedit' button property set to true. All functionalites are working fine except that tooltip is not displaying for the autogenerated update and cancel buttons, instead it displays tooltip as 'edit' itself which is the tooltip for 'edit' button. It is displaying correctly in IE compatibility view but not in IE 8 or Chrome or FF browsers!. I searched in net, most solutions suggested to use template field instead of command field, my problem is at this stage implementing template field will result in lot of code changes. Please suggest whether this is possible in Command field itself! The gridview design code is given below:

<asp:CommandField ButtonType="Image" ShowEditButton="True" ValidationGroup="EditAnswer" CancelImageUrl="../images/Cancel.jpg" CancelText="Click to cancel" UpdateImageUrl="../images/Update.jpg" UpdateText="Click to save this answer" EditImageUrl="../images/Edit.jpg" EditText="Click to edit this answer">              <ControlStyle CssClass="para1" />                                                      <ItemStyle HorizontalAlign="Center" Width="10%" />                             </asp:CommandField>

I tried setting tooltip for autogenerated update and cancel buttons also but this also failed because I am not able to get the controls for update and cancel buttons in row databound event.

1条回答
男人必须洒脱
2楼-- · 2019-08-16 05:46

I have implemented this functionality using command field itself in gridview's row databound event,

    if (e.Row.RowType == DataControlRowType.DataRow)
    {            
        e.Row.Cells[2].ToolTip = "Click to Edit answer";
        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) == 2)
                {
                    ((System.Web.UI.WebControls.ImageButton)(e.Row.Cells[2].Controls[0])).ToolTip = "Click to update answer";
                    ((System.Web.UI.LiteralControl)(e.Row.Cells[2].Controls[1])).Text = "&nbsp;";
                    ((System.Web.UI.WebControls.ImageButton)(e.Row.Cells[2].Controls[2])).ToolTip = "Click to cancel answer";
                }
                i++;
            }
        }
    }

This code works fine in all browsers!

查看更多
登录 后发表回答