Trying to output variables into repeater
Posted
by Phil
on Stack Overflow
See other posts from Stack Overflow
or by Phil
Published on 2010-04-16T12:44:33Z
Indexed on
2010/04/16
12:53 UTC
Read the original article
Hit count: 451
I have a downloads box which attaches to the bottom of the page and gives the user file downloads (icon, filesize, description) like this;
<asp:Repeater ID="DownloadsRepeater" runat="server">
<HeaderTemplate>
<table width="70%">
<tr>
<td colspan="3"><h2>Files you can download:</h2></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="10%">
<a href="/documents/<%=Session("folder")%>/<%=filename%>">
<img src="images/<%=filename%>" border="0" alt="<%=filename%>" /></a>
</td>
<td width="25%"><% =filesize%></td>
<td><a href="/documents/<%=Session("folder")%>/<%=filename%>"><%=description%></a></td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
Then I have code in my code behind to get the data etc like this;
s = "select documents.filename, documents.description, documents.filesize from documents, contentdocuments, content where contentdocuments.contentid = content.id and content.id = @contentid and contentdocuments.documentsid = documents.id ORDER BY documents.description"
x = New SqlCommand(s, c)
x.Parameters.Add("@contentid", SqlDbType.Int)
x.Parameters("@contentid").Value = contentid
c.Open()
r = x.ExecuteReader
While r.Read
If r.HasRows Then
filename = getimage(r("filename"))
If r("filesize") > String.Empty Then
filesize = (r("filesize") / 1000) & "kb"
End If
description = r("description")
End If
DownloadsRepeater.DataSource = r
DownloadsRepeater.DataBind()
End While
The desired result is that the user sees a file download icon, the filesize and the description. with the icon and the description being linked to the file. Can someone point out where I am going wrong and possibly post a sample of correct syntax for achieving this. Thanks!
© Stack Overflow or respective owner