webwiz082
04-10-2007, 08:35 PM
Hi all:
Let's say I have a datagrid on my website. The values to this datagrid are below:
AttachmentID
697
698
699
700
Each of those 3-digit numbers represents an AttachmentID (which ultimately represents an image). What I want to do is create an image tag for each one of those, but I have no idea how to loop through a datagrid. I have an "attachmentHandler" page which actually retreives the image for each AttachmentID. So if I had this code:
<asp:Image ID="image11" runat="server" ImageUrl="~/Handlers/AttachmentHandler.ashx?AttachmentID=697"></asp:Image>
<asp:Image ID="image12" runat="server" ImageUrl="~/Handlers/AttachmentHandler.ashx?AttachmentID=698"></asp:Image>
I would get two of the correct images. The code on my website is below:
Dim MySQL2 As SQLCommand
MySQL2 = New SqlCommand("SELECT AttachmentID from Attachments where ArticleID=" & Article, DBConnection)
Dim dt as New DataTable()
Dim dcName as New DataColumn("AttachmentID", GetType(Integer))
dt.Columns.Add(dcName)
Dim DataAdapter As New SqlDataAdapter
MySQL2.ExecuteNonQuery()
DataAdapter.SelectCommand = MySQL2
DataAdapter.Fill(dt)
dgPeople.DataSource = dt
dgPeople.DataBind()
So all I wanna do is loop through the datagrid, and for each row in the datagrid, place an image tag in a string which captures the Attachment ID at the very end of it. Something like this:
Dim Image as String
Dim row As DataGridItem
For Each row In dgPeople.Items
Image = "<img src="~/Handlers/AttachmentHandler.ashx?AttachmentID= " & AttachmentID & >"
Next
Then I have to find out a way to actually use the Image string to display the images.
Any help would be appreciated.
Thanks,
-Wes
Let's say I have a datagrid on my website. The values to this datagrid are below:
AttachmentID
697
698
699
700
Each of those 3-digit numbers represents an AttachmentID (which ultimately represents an image). What I want to do is create an image tag for each one of those, but I have no idea how to loop through a datagrid. I have an "attachmentHandler" page which actually retreives the image for each AttachmentID. So if I had this code:
<asp:Image ID="image11" runat="server" ImageUrl="~/Handlers/AttachmentHandler.ashx?AttachmentID=697"></asp:Image>
<asp:Image ID="image12" runat="server" ImageUrl="~/Handlers/AttachmentHandler.ashx?AttachmentID=698"></asp:Image>
I would get two of the correct images. The code on my website is below:
Dim MySQL2 As SQLCommand
MySQL2 = New SqlCommand("SELECT AttachmentID from Attachments where ArticleID=" & Article, DBConnection)
Dim dt as New DataTable()
Dim dcName as New DataColumn("AttachmentID", GetType(Integer))
dt.Columns.Add(dcName)
Dim DataAdapter As New SqlDataAdapter
MySQL2.ExecuteNonQuery()
DataAdapter.SelectCommand = MySQL2
DataAdapter.Fill(dt)
dgPeople.DataSource = dt
dgPeople.DataBind()
So all I wanna do is loop through the datagrid, and for each row in the datagrid, place an image tag in a string which captures the Attachment ID at the very end of it. Something like this:
Dim Image as String
Dim row As DataGridItem
For Each row In dgPeople.Items
Image = "<img src="~/Handlers/AttachmentHandler.ashx?AttachmentID= " & AttachmentID & >"
Next
Then I have to find out a way to actually use the Image string to display the images.
Any help would be appreciated.
Thanks,
-Wes