Alternate text for GridImageColumn

2 posts, 0 answers
  1. Christopher Bodnar
    Christopher Bodnar avatar
    7 posts
    Member since:
    Sep 2009

    Posted 24 Nov 2009 Link to this post


    I am using a GridImageColumn to display images.  However, I need data specific alternate text for each image for screen readers to pick up, like what the Tool Tip displays.  The AlternateText attibute is generic for the whole column and the DataAlternateTextField doesn't display if the images are missing.  Can anybody suggest a way to get data bound alternate text for this type of column.

    Thank you,

  2. Roland
    Roland avatar
    156 posts
    Member since:
    Feb 2009

    Posted 24 Nov 2009 Link to this post


    There is another way.

    Instead of using GridImageColumn, you can use Templated Column
    <telerik:GridTemplateColumn UniqueName="Column1" DataField="Field1"
                        <HeaderStyle Width="32px"></HeaderStyle> 
                             <asp:Image id="myImg" runat="server"/> 


    protected void grid_ItemDataBound(object sender, GridItemEventArgs e) 
                if (e.Item.ItemType != GridItemType.AlternatingItem && e.Item.ItemType != GridItemType.Item) 
     var img = e.Item.FindControl("myImg"as Image; 
    img.AlternateText = "my alternate text"
      var dataItem = e.Item.DataItem as MyDataBoundObject; 
    img.AlternateText = dataItem.AltText; 

    Assuming your grid is bound to collection of MyDataBoundObject and it has AltText property/field.
  3. DevCraft R3 2016 release webinar banner
Back to Top