Display Image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jeenajos
    New Member
    • Oct 2007
    • 71

    #1

    Display Image

    Hi all,

    Im working with Datagrid for image manipulation.I have an image upload part which work as uploading an image in Server Map Path and storing the image path in database .I displays the image name in datagrid. The thing i want is, hw can i display the image in a placeholder wen i click that link in Datagrid?

    Can anyone suggest an idea.?Is there any other option?Whether this concept works?

    And also is it possible to return a value from a set of code to another set?Pls give me its format.Im really a new to .net.

    Thanks
  • kunal pawar
    Contributor
    • Oct 2007
    • 297

    #2
    If your Image is store in data base then u can show image in image tag with assigning navigationrl/src = .aspx whose content type is image

    this is code for .aspx page

    <%@ Page Language="vb" AutoEventWireup ="false" %>
    <%@import Namespace=Syste m.IO %>
    <%@Import namespace=Syste m.Data.SqlClien t %>
    <%@Import namespace= System.Threadin g %>
    <%@Import namespace= System %>
    <%@Import namespace= System.Data %>
    <%@Import namespace= System.Web %>
    <%@ Import Namespace="Syst em.Drawing" %>
    <%@Import namespace= System.Drawing. Bitmap %>
    <%@ Import Namespace="Syst em.Configuratio n" %>
    <%@ Import Namespace="Syst em.Drawing.Imag ing" %>
    <%@Import namespace= System.Web.UI.W ebControls.Imag e %>
    <script runat="server">
    Dim con As SqlConnection
    Dim cmd As SqlCommand
    Dim dr As SqlDataReader

    </script>
    <%

    con = New SqlConnection(C onfigurationMan ager.Connection Strings("deskto pConnectionStri ng").Connection String.ToString ())
    con.Open()
    Dim ret_img As String
    ret_img = "SELECT B.TITLE, B.IMAGEPATH FROM SESSION where IMAGE_ID='" + Request.QuerySt ring("imageid") + "' "

    cmd = New SqlCommand(ret_ img, con)
    dr = cmd.ExecuteRead er
    Dim imagedata As Byte()
    Dim bmp As Bitmap
    If dr.HasRows Then
    dr.Read()
    imagedata = dr.Item(0)
    If imagedata.Lengt h > 0 Then
    Dim srm As MemoryStream = New MemoryStream(im agedata, True)
    srm.Write(image data, 0, imagedata.Lengt h)

    Try

    bmp = Bitmap.FromStre am(srm)
    Dim g As Graphics = Graphics.FromIm age(bmp)

    Response.Conten tType = "image/JPEG"
    bmp.Save(Respon se.OutputStream , ImageFormat.Jpe g)

    Catch ex As Exception
    ' Response.Write( ex.Message)
    End Try

    End If
    End If
    %>

    Comment

    • jeenajos
      New Member
      • Oct 2007
      • 71

      #3
      Hi,
      Thanks for the response,
      But i didnt stored the image in database, i only stored the image name(filename) in databse.Image is in Sever.MapPath.
      Now the situation is that i displayed the filename in datagrid, wen i click that filename it should display the image in a placeholder.
      Any solution for that?

      Thank U.

      Comment

      Working...