2

There is a AlternateText property in image-buttons so that while hovering mouse on image buttons, alternate text could clarify the functionality of the button. I want to do so with ASP.net standard gridview and show a text while mouse being stopped on buttonfield button that I've added to my gridview. But such a property does not exist and my searches using Intellisense reached nowhere.

p.campbell
  • 98,673
  • 67
  • 256
  • 322
Farshid
  • 5,134
  • 9
  • 59
  • 87

2 Answers2

3

If you specify the Text property on the ButtonField of a ButtonField that has a ButtonType of Image the text will be used as the Alternate Text for the image.

<asp:GridView ID="grdRegistrations" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:ButtonField ButtonType="Image" ImageUrl="~/img/detail.gif" Text="View Registration"  />
...
2

Use TemplateField instead of ButtonField like below:

<asp:TemplateField>
    <ItemTemplate>
       <asp:ImageButton ID="ImageButton1" runat="server" AlternateText="My Text" />
    </ItemTemplate>
</asp:TemplateField>
gbs
  • 7,196
  • 5
  • 43
  • 69
  • If you are using the gridview builder in Visual Studio, you can also select the buttonfield column and click 'convert to template field' in the lower left. – Maximillian Dec 29 '10 at 16:07