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. need help on Image control in the datalist

need help on Image control in the datalist

Scheduled Pinned Locked Moved ASP.NET
help
3 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.
  • H Offline
    H Offline
    hurrem
    wrote on last edited by
    #1

    Hi, I have a very interesting problem, my code doesn't show any errors or exceptions, but when I'm running the web-page, it still doesn't work properly. I want to bind an image on an image control, which is inside the Datalist and Datalist is inside the DetailsView. When I'm debugging the code, it shows me the imageURL path very well, but doesn't show me the image in the browser. My Select statement si : SelectCommand="SELECT [Source] FROM [Images] WHERE ([NID] = @NID) Here is my code on page load: string nID = Request.QueryString["nID"].ToString(); DataView view = (DataView)ImagesSqlDataSource.Select(DataSourceSelectArguments.Empty); int count = (int)view.Table.Rows.Count; Label username = (Label)NDetailsView.FindControl("UsernameLabel"); DataList ImagesDataList = (DataList)NDetailsView.FindControl("ImagesDataList"); for (int i = 0; i < count; i++) { Image image = (Image)ImagesDataList.Items[i].FindControl("ImageControl"); string imagename = (string)view.Table.Rows[i].ItemArray[0]; image.ImageUrl = Request.PhysicalApplicationPath + @"Images\" + username.Text + "\\" + nID + "\\" + imagename; } Thank you

    R 1 Reply Last reply
    0
    • H hurrem

      Hi, I have a very interesting problem, my code doesn't show any errors or exceptions, but when I'm running the web-page, it still doesn't work properly. I want to bind an image on an image control, which is inside the Datalist and Datalist is inside the DetailsView. When I'm debugging the code, it shows me the imageURL path very well, but doesn't show me the image in the browser. My Select statement si : SelectCommand="SELECT [Source] FROM [Images] WHERE ([NID] = @NID) Here is my code on page load: string nID = Request.QueryString["nID"].ToString(); DataView view = (DataView)ImagesSqlDataSource.Select(DataSourceSelectArguments.Empty); int count = (int)view.Table.Rows.Count; Label username = (Label)NDetailsView.FindControl("UsernameLabel"); DataList ImagesDataList = (DataList)NDetailsView.FindControl("ImagesDataList"); for (int i = 0; i < count; i++) { Image image = (Image)ImagesDataList.Items[i].FindControl("ImageControl"); string imagename = (string)view.Table.Rows[i].ItemArray[0]; image.ImageUrl = Request.PhysicalApplicationPath + @"Images\" + username.Text + "\\" + nID + "\\" + imagename; } Thank you

      R Offline
      R Offline
      Rama Krishna Vavilala
      wrote on last edited by
      #2

      You are using Request.PhysicalApplicationPath which is not correct. This will translate to c:\inetputb\wwwroot or something like that. Easiest way to fix the issue is:

      image.ImageUrl = new StringBuilder(@"~/Images/").Append(username.Text)
      .Append(nID).Append("/").Append(imagename).ToString();

      Co-Author ASP.NET AJAX in Action

      H 1 Reply Last reply
      0
      • R Rama Krishna Vavilala

        You are using Request.PhysicalApplicationPath which is not correct. This will translate to c:\inetputb\wwwroot or something like that. Easiest way to fix the issue is:

        image.ImageUrl = new StringBuilder(@"~/Images/").Append(username.Text)
        .Append(nID).Append("/").Append(imagename).ToString();

        Co-Author ASP.NET AJAX in Action

        H Offline
        H Offline
        hurrem
        wrote on last edited by
        #3

        Thank you!!!!!!!!!!!!! :)

        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