Reputation: 2186
I am trying to add a tool type to my command buttons on my gridview, but I am a bit stuck.
Here's the markup...
<asp:CommandField ButtonType="Link" ShowEditButton="true" EditText="!" ShowDeleteButton="true" DeleteText="3" CancelText="O" ItemStyle-CssClass="View1 View2 View3" ItemStyle-Width="45px" UpdateText="P">
<ControlStyle Font-Names="'WingDings 2'" ForeColor="Black" Font-Size="16px" />
</asp:CommandField>
When I breakpoint in code-behind and look at what is in e.Row.Cells
, it is a collection of DataControlLinkButton
but I cannot seem to find any reference to this in documentation to see if there's a tooltip
I can set.
Upvotes: 0
Views: 1357
Reputation: 3681
You could set it on RowDataBound
of Gridview
.
i am sharing a code snippet from one of my implementations.
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowState == DataControlRowState.Edit || e.Row.RowState.ToString() == "Alternate, Edit")
{
foreach (TableCell cell in e.Row.Cells)
{
if (e.Row.Cells.GetCellIndex(cell) == 4)
{
((System.Web.UI.WebControls.LinkButton)(e.Row.Cells[4].Controls[2])).ToolTip = "Tooltip goes here";
}
}
}
}
}
catch (Exception _e)
{
}
}
Hope this helps..
Upvotes: 1