Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to display an image in gridview

how to display an image in gridview

Scheduled Pinned Locked Moved ASP.NET
databasesysadminsecurityhelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Meax
    wrote on last edited by
    #1

    i have uploaded the image file using asp fileupload control. i am uploading files to this folder: F:\MySite\FileManager\MyUserName saved the file name and file path to database. in my database i have DocumetName TestImage.JPG and Path F:\MySite\FileManager\MyUserName\TestImage.JPG

    <asp:TemplateField headertext="picture">
    <ItemTemplate>
    <asp:Image ID="Image2" width="40" runat="server" imageurl='<%# Eval("DocumentName") %>' /> <br/>
    </itemtemplate>
    </asp:TemplateField>

    i tried like this(use Path instead of DocumentName) aslo but it doesn't show any image and no error also

    <asp:TemplateField headertext="picture">
    <ItemTemplate>
    <asp:Image ID="Image2" width="40" runat="server" imageurl='<%# Eval("Path") %>' /> <br/>
    </itemtemplate>
    </asp:TemplateField>

    i am using this to get all file details

    Private Sub GetAllTheImages()

        ' Declare objects...
        Dim objConnection As SqlConnection = New \_
            SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MyDB;Data Source=MY\\SQLEXPRESS")
    
        objConnection.Open()
    
        Dim myCommand As New System.Data.SqlClient.SqlCommand()
        myCommand.Connection = objConnection
    
        myCommand.CommandText = "GetAllTheImages"
        myCommand.CommandType = CommandType.StoredProcedure
    
    
        Dim param As New System.Data.SqlClient.SqlParameter()
    
    
        Dim myAdapter As New SqlDataAdapter(myCommand)
    
        myAdapter.Fill(GetAllTheImages)
    
        Dim reader As SqlDataReader = myCommand.ExecuteReader()
    
    
        GV1.DataSource = GetAllTheImages
    
        GV1.DataBind()
    
        objConnection.Close()
    
    End Sub
    
    D 1 Reply Last reply
    0
    • M Meax

      i have uploaded the image file using asp fileupload control. i am uploading files to this folder: F:\MySite\FileManager\MyUserName saved the file name and file path to database. in my database i have DocumetName TestImage.JPG and Path F:\MySite\FileManager\MyUserName\TestImage.JPG

      <asp:TemplateField headertext="picture">
      <ItemTemplate>
      <asp:Image ID="Image2" width="40" runat="server" imageurl='<%# Eval("DocumentName") %>' /> <br/>
      </itemtemplate>
      </asp:TemplateField>

      i tried like this(use Path instead of DocumentName) aslo but it doesn't show any image and no error also

      <asp:TemplateField headertext="picture">
      <ItemTemplate>
      <asp:Image ID="Image2" width="40" runat="server" imageurl='<%# Eval("Path") %>' /> <br/>
      </itemtemplate>
      </asp:TemplateField>

      i am using this to get all file details

      Private Sub GetAllTheImages()

          ' Declare objects...
          Dim objConnection As SqlConnection = New \_
              SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MyDB;Data Source=MY\\SQLEXPRESS")
      
          objConnection.Open()
      
          Dim myCommand As New System.Data.SqlClient.SqlCommand()
          myCommand.Connection = objConnection
      
          myCommand.CommandText = "GetAllTheImages"
          myCommand.CommandType = CommandType.StoredProcedure
      
      
          Dim param As New System.Data.SqlClient.SqlParameter()
      
      
          Dim myAdapter As New SqlDataAdapter(myCommand)
      
          myAdapter.Fill(GetAllTheImages)
      
          Dim reader As SqlDataReader = myCommand.ExecuteReader()
      
      
          GV1.DataSource = GetAllTheImages
      
          GV1.DataBind()
      
          objConnection.Close()
      
      End Sub
      
      D Offline
      D Offline
      D4ever
      wrote on last edited by
      #2

      it's simple you just have to add a ImageField in Gridview. Just select the Gridview & click on the arrow shown on Right side(Gridview Tasks)and Add New Column -->select ImageField(Choose a Field Type) & give your column name i.e the column having Path , used in the query to bind the gridview,in Data field If still not getting then revert back on my mail Id

      Darshana Pathak

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups