Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
670
Displaying Image in Column Header (at runtime)
posted

I want to place an image into the Grid Column's Header instead of Caption Text at run time.  I have seen how to do this at design time (https://www.youtube.com/playlist?list=PLDAFFE8C757FED32E). I attempted to translate this into dynamically creating this at run time, but I am missing something.  How do I do this for the WebDataGrid?

Here is what is created during design time:

            <Templates>
                <ig:ItemTemplate ID="WebDataGrid1Template1" runat="server" 
                    TemplateID="Comments">
                    <Template>
                      <img src="images/Notes.png" alt="Comments" />
                    </Template>
                </ig:ItemTemplate>
            </Templates>

I tried to create it like this but it does not work (no image shows up):

Dim commentsHeader As Infragistics.Web.UI.ItemTemplate = New Infragistics.Web.UI.ItemTemplate()
 
commentsHeader.TemplateID = "Comments"
 
Dim commentsImage As System.Web.UI.WebControls.Image = New System.Web.UI.WebControls.Image()
 
commentsImage.ImageAlign = ImageAlign.Middle
commentsImage.AlternateText = "Comments"
commentsImage.ImageUrl = "images/Notes.png"
  
commentsHeader.Controls.Add(commentsImage)
WebDataGrid1.Templates.Add(commentsHeader)

Thanks for your help.

Parents
  • 29417
    Offline posted
    Hello greghendricks ,
     Thank you for posting in our forum.
    Please refer to the following link to our documentation:
     
    Under the explanation on how to add template columns with Item template from the designer and mark-up you’ll find how to do the same steps in the code behind.
    To create a custom Item template you need to create a class that implements ITemplate interface and set an instance of it to the ItemTemplate property of the column. You’ll see the code sample in the provided link.
     
    Let me know if you need further assistance with this issue.
     
     
    Best Regards,
    Maya Kirova
    Developer Support Engineer
    Infragistics, Inc.

     
Reply Children