Click here to Skip to main content
15,908,111 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to create Fast food Point of sale in asp.net i want to load pictures in List view same i done in Window form and its working but in web form its giving an error of imagelist when im trying to decalre
Dim imglist As New <big>ImageList</big>


and also in
ListView1.LargeImageList = imglist
   ListView1.LargeImageList.ImageSize = New System.Drawing.Size(100, 100)

and third error in

Dim lsvparent As New ListViewItem

             lsvparent.Text = dr("Product_Id").ToString
             lsvparent.ImageKey = dr("Product_Id").ToString


What I have tried:

Private Sub retriveBurger()
        Try
            Dim conn As SqlConnection
            Dim cmd As SqlCommand
            Dim da As SqlDataAdapter
            Dim ds As DataSet
            ListView1.Items.Clear()
            Dim imglist As New ImageList
            imglist.ColorDepth = ColorDepth.Depth32Bit

            ListView1.LargeImageList = imglist
            ListView1.LargeImageList.ImageSize = New System.Drawing.Size(100, 100)
            conn = New SqlConnection(ConfigurationManager.ConnectionStrings("connectionstring").ConnectionString)
            Dim strQ As String = String.Empty
            strQ = "SELECT * from Information where Category='Burger' AND Status='Active' AND Status='Active' order by id"
            Dim dt_images As New DataTable
            cmd = New SqlCommand(strQ, conn)
            da = New SqlDataAdapter(cmd)
            ds = New DataSet
            da.Fill(dt_images)
            For Each dr As DataRow In dt_images.Rows
                Dim img_buffer = CType(dr("Photo"), Byte())
                Dim img_stream As New MemoryStream(img_buffer, True)
                img_stream.Write(img_buffer, 0, img_buffer.Length)
                imglist.Images.Add(dr("Product_Id").ToString(), New Bitmap(img_stream))
                img_stream.Close()
                Dim lsvparent As New ListViewItem

                lsvparent.Text = dr("Product_Id").ToString
                lsvparent.ImageKey = dr("Product_Id").ToString

                ListView1.Items.Add(lsvparent)


            Next


        Catch ex As Exception

        End Try


    End Sub
Posted
Updated 5-Dec-20 21:32pm

1 solution

ImageList is a class that is only available in WinForms apps - not online. You could include it in your code by adding the appropriate reference and using line, but it would still be of no use to you because web controls do not understand it and can;t access images from it. You need to access each image individually, you cna;t just put them in a list and provide an index.

BTW:
SQL
SELECT * from Information where Category='Burger' AND Status='Active' AND Status='Active' order by id

You have the same condition twice there, and shouldn't be storing the Status as a string anyway. Instead, set up a second table "Statuses" which contains an IDENTITY column "Id" and a string "Description" then us that as a FOREIGN KEY field in you main table. You can "tie them together" using a JOIN, but it means you don't get duplicate data in your table and that data entry uses the names and can't misspell the status code.

And please, don't use SELECT * - it's considered very bad practice. Always list the columns you want in the order you want them - that way you aren't fetching data you don't use and wasting memory and bandwidth.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900