How to create a Template Column with an Image in a datagrid?

Discussion in 'ASP .Net' started by Shapper, Jun 21, 2005.

  1. Shapper

    Shapper Guest

    Hello,

    How to create a Template Column with an Image in a datagrid from my VB
    code?

    Thanks,
    Miguel
    Shapper, Jun 21, 2005
    #1
    1. Advertising

  2. Hi,
    First you need to create a TemplateColumn and add it to the datagrid.
    Dim tmpCol As TemplateColumn
    tmpCol = New TemplateColumn
    DataGrid1.Columns.Add(tmpCol)

    Then on the DataGrids itemBound event you have to add an image to the cell.
    Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    DataGrid1.ItemDataBound
    Dim imgTemp As New System.Web.UI.HtmlControls.HtmlImage
    imgTemp.Src = "..."(Path of the image)
    e.Item.Cells(0).Controls.Add(imgTemp)
    End Sub
    PS:I have given a simplest way of getting an image column in a datagrid.
    --
    HTH
    srini
    http://www.expertszone.com


    "Shapper" wrote:

    > Hello,
    >
    > How to create a Template Column with an Image in a datagrid from my VB
    > code?
    >
    > Thanks,
    > Miguel
    >
    >
    =?Utf-8?B?c3Jpbmk=?=, Jun 21, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Hammond
    Replies:
    1
    Views:
    3,616
    bruce barker
    Nov 26, 2003
  2. Dexter
    Replies:
    1
    Views:
    418
    Eliyahu Goldin
    Jan 18, 2005
  3. Ken Varn
    Replies:
    1
    Views:
    975
    Ken Varn
    Aug 19, 2005
  4. Charleees
    Replies:
    2
    Views:
    8,208
    Eliyahu Goldin
    Jun 20, 2006
  5. Ravichandran Mahalingam

    Bound Column or Template Column (w dAdapater?) in DataGrid

    Ravichandran Mahalingam, Jan 9, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    220
    Ravichandran Mahalingam
    Jan 9, 2004
Loading...

Share This Page