Solved

How to retrieve an image from sql server database to an asp.net table control ?

Posted on 2009-07-08
4
233 Views
Last Modified: 2012-05-07
In my project I am using the following manner to retrieve the images from database ...

Private Sub GenerateTableData(ByVal orgid As Integer)
        Dim str As String
        Dim cmd As New SqlCommand
        Dim conn As New SqlConnection(connStr)
        conn.Open()
        str = "Select productid, productname from tblproduct WHERE originid=" & orgid
        Try
            cmd = New SqlCommand(str, conn)
            Dim dtr As New SqlDataAdapter(cmd)
            Dim dst As New DataSet
            dst.Clear()
            dtr.Fill(dst, "po")
            Dim tr As TableRow
            Dim td As TableCell
            Dim i, j As Integer
            For i = 0 To dst.Tables(0).Rows.Count - 1
                tr = New TableRow
                td = New TableCell
                td.Width = 167
                td.HorizontalAlign = HorizontalAlign.Center
                td.VerticalAlign = VerticalAlign.Middle
                Dim prodId As Integer = dst.Tables(0).Rows(i).Item(0)
                td.Text = "ABC" & "<asp:Image ID='Image" & i & "' runat='server' ImageUrl='imgGrab.aspx?tab=tblproduct&showfld=smallimage&condfld=productid&id=" & prodId & "' ImageAlign='middle' />"
                tr.Cells.Add(td)
                Table1.Rows.Add(tr)
            Next
        Catch ex As Exception
            Throw
        Finally
            conn.Close()
        End Try

My Output is :
ABC
ABC
(As only 2 records in the table)
But no image is showing in the table. If I copy paste the code of image control directly in the page it is showing the image. so i think my ImgGrab.aspx is working fine.
will you pls help me in this regard ???
its urgent ...
0
Comment
Question by:akulavi
  • 3
4 Comments
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 24801457
0
 

Author Comment

by:akulavi
ID: 24801470
I am following ur links... but it will be helpful for me if u pls rectify my code which i had already stated above...... because the same code if I am using in an image control it is showing me the image , but if I write the code as the text of of TableCell control then it is not showing ...
0
 

Author Comment

by:akulavi
ID: 24801478
Moreover, My requirement is very specific ..... whether we can use the tablecell's text as I had stated earlier or we cannot use the image control..... If yes then whether my way is ok or not ....
0
 

Accepted Solution

by:
akulavi earned 0 total points
ID: 24801698
I have solved my problem using the <img >control of html.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now