Make detail page with images (based on categoryID)

Ø

Øyvind Isaksen

I need to make a page that shows the "top 1" article in a spesific category,
with pictures stored in another table. If I just should display the article,
I would use a datareader and bind title, ingress and body to labels.

This is how I bind the article to the labels:

Private Sub article()
Dim SQL As String = "select top 1 artID,title,ingress,body from
tblArticle where catID=@catID"
Dim conn As New SqlConnection(variables.connString)
Dim cmd As New SqlCommand(SQL, conn)
Dim parameter As New SqlParameter("@catID",
request.querystring("catID"))
cmd.Parameters.Add(parameter)

cmd.Connection.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
While dr.Read
Me.lblTitle.Text = dr.Item("title")
Me.lblIngress.Text = Replace(dr.Item("ingress"), Chr(13),
"<br>")
Me.lblBody.Text = Replace(dr.Item("body"), Chr(13), "<br>")
End While
cmd.Connection.Close()

cmd.Dispose()
conn.Dispose()
End Sub


My question comes when I shall get the images to this article, and bind them
to a Repeater.
Can I do this in the same procedure (when I bind title, ingress and body to
the labels), or should I make a new procedure to get the images? How do I
get the articleID from the first procedure, I need this to get the correct
images...


This is how I bind the images to the repeater, but I DONT have the article
ID (inputArtID):

Private Sub images(ByVal inputArtID)
Dim SQL As String = "select path from tblImage where artID=@artID"
Dim conn As New SqlConnection(variables.connString)
Dim cmd As New SqlCommand(SQL, conn)
Dim parameter As New SqlParameter("@artID", inputArtID)
cmd.Parameters.Add(parameter)

cmd.Connection.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
Me.rptImages.DataSource = dr
Me.rptImages.DataBind()
cmd.Connection.Close()

cmd.Dispose()
conn.Dispose()
End Sub



How do I get the article ID(artID) from the article Procedure and use this
in the images Procedure???
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top