Part 5 - Template Columns.
Then in the code for the ItemDataBound event you add the HTML for the image.
If you want the image to be a link as well, then add the <A> tags. Eg:
Sub AddImage(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
If e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <>
ListItemType.Footer Then
e.Item.Cells(4).Text() = "<img src='../images/picture.gif'></img>"
End If
End Sub
Don't forget you need to add a template column to the datagrid, and set the
OnItemDataBound="AddImage" property for the datagrid.
(For the above code, the template column would need to be the 4th column)
<Columns>
<asp:BoundColumn......></asp:BoundColumn>
<asp:BoundColumn......></asp:BoundColumn>
<asp:BoundColumn......></asp:BoundColumn>
<asp:TemplateColumn HeaderText="No.">
<ItemTemplate>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
Nick
"Bart Schelkens" <BS********@hotmail.com> wrote in message
news:eN****************@TK2MSFTNGP09.phx.gbl...
Thx for the info
but i can't find the section where they explain how to display images in
the grid.
Nor can i find the section where they tell me how to display an image that
serves as a link for a new page.
"Nick" <Ni**@NTWorks.no.spam.fsnet.co.uk> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... This is a very good article with extra datagrid info:
http://aspnet.4guysfromrolla.com/articles/040502-1.aspx
"Bart Schelkens" <BS********@hotmail.com> wrote in message
news:Om*************@TK2MSFTNGP12.phx.gbl... Jared,
thx for the answer.
My email is a valid address BS********@hotmail.com
So there's no problem in sending me a reply there.
Thx.
Bart
"Jared" <VB***********@email.com> wrote in message
news:10*************@corp.supernews.com...
>
> 1:) You can use a datareader to fill a datalist/datagrid.
>
> Dim Conn As New System.Data.SqlClient.SqlConnection
> Conn.ConnectionString = "Server=YourServer;
> Database=Northwind;Trusted_Connection=True;"
>
> Conn.Open()
>
> Dim cmd As New SqlClient.SqlCommand("SELECT * FROM Employees", Conn) > Me.DataGrid2.DataSource = cmd.ExecuteReader
> Me.DataGrid2.DataBind()
>
> Conn.Close()
>
> 2:)
> If no one else answers your question, before I get home from work I will > throw together an example for you. Is your e-mail address valid?
>
> Jared
>
> "Bart Schelkens" <BS********@hotmail.com> wrote in message
> news:%2****************@TK2MSFTNGP09.phx.gbl...
> > Hi,
> >
> > I have 2 more questions :
> >
> > 1. Can I fill a datagrid by using a DataReader or does it have to
be a > > DataSet or a DataView?
> >
> > 2. In my datagrid I need to display two images and one of does images has
> > te
> > be a link to a new page. How would you do that ?
> >
> > Thanks.
> >
> >
>
>