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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. displaying image in gridview from folder

displaying image in gridview from folder

Scheduled Pinned Locked Moved ASP.NET
sysadminhelp
3 Posts 3 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.
  • J Offline
    J Offline
    Jai Vikas Singh
    wrote on last edited by
    #1

    Hi, I have to display images from a folder in imagefield. I am using following code but its not showing the image. Please help!

    DataTable dt = new DataTable();
    // dt.Columns.Add("S.No", typeof(string));
    dt.Columns.Add("NeckLace", typeof(string));
    DataRow dr;
    int i = 1;
    foreach (string file in Directory.GetFiles(Server.MapPath(@"NeckLace\")))
    {
    //string nm = Path.GetFileName(file);
    dr = dt.NewRow();
    // dr[0] = i.ToString();
    dr[0] = ResolveUrl(file);
    dt.Rows.Add(dr);
    i += 1;
    }
    GridView1.DataSource = dt;
    GridView1.DataBind();

    K 1 Reply Last reply
    0
    • J Jai Vikas Singh

      Hi, I have to display images from a folder in imagefield. I am using following code but its not showing the image. Please help!

      DataTable dt = new DataTable();
      // dt.Columns.Add("S.No", typeof(string));
      dt.Columns.Add("NeckLace", typeof(string));
      DataRow dr;
      int i = 1;
      foreach (string file in Directory.GetFiles(Server.MapPath(@"NeckLace\")))
      {
      //string nm = Path.GetFileName(file);
      dr = dt.NewRow();
      // dr[0] = i.ToString();
      dr[0] = ResolveUrl(file);
      dt.Rows.Add(dr);
      i += 1;
      }
      GridView1.DataSource = dt;
      GridView1.DataBind();

      K Offline
      K Offline
      kenexcelon
      wrote on last edited by
      #2

      You may have to catch that in the databound event possibly and add a literal control with the image tag pointing to where it should go?

      Revolutionary: Disk drives go round and round.

      R 1 Reply Last reply
      0
      • K kenexcelon

        You may have to catch that in the databound event possibly and add a literal control with the image tag pointing to where it should go?

        Revolutionary: Disk drives go round and round.

        R Offline
        R Offline
        raghvendrapanda
        wrote on last edited by
        #3

        Thanks Mate! I got it.

        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