Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello... i'm trying to create an image column in a datagrid but it isn't working(both the boundcolumn and the hyperlink column are working fine). Below i'm posting both the asp.net code from my datagrid and the vb code from database connection. Can anyone tell me why it isn't working????

 

Datagrid code

---------------------------------------------------------------------------------------------------------------------------

<asp:dataGrid id="dgrid" runat="server" Font-Size="X-Small" AllowSorting="True" AutoGenerateColumns="False">

<Columns>

<asp:TemplateColumn HeaderText="Thumbnail">

<ItemTemplate>

<asp:Image ImageUrl='/revelaqui/fotos/<%#Container.DataItem("albuns.utilizador")%>/thumbs/thumb<%#Container.DataItem("fotos.urlfoto")%>' Runat="server">

</asp:Image>

</ItemTemplate>

</asp:TemplateColumn>

<asp:HyperLinkColumn DataNavigateUrlField="urlLink" DataTextField="titulo" HeaderText="Titulo"></asp:HyperLinkColumn>

<asp:BoundColumn DataField="dataUpload" HeaderText="Data de upload"></asp:BoundColumn>

</Columns>

</asp:dataGrid>

---------------------------------------------------------------------------------------------------------------------------

database connection code

---------------------------------------------------------------------------------------------------------------------------

Dim dbconn, dbcomm, sql

Dim username As String = CStr(Session("utilizador"))

dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("bd/fotodados.mdb"))

sql = "SELECT fotos.urlfoto, fotos.titulo, fotos.dataUpload, fotos.urlLink, albuns.utilizador FROM fotos INNER JOIN albuns ON albuns.IdAlbum=fotos.idAlbum WHERE (albuns.titulo='As minhas fotografias' AND albuns.utilizador='" & username & "')"

dbcomm = New OleDbCommand(sql, dbconn)

dbconn.Open()

dgrid.DataSource = dbcomm.ExecuteReader()

dgrid.DataBind()

dbconn.Close()

---------------------------------------------------------------------------------------------------------------------------

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...