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. display image to datalist

display image to datalist

Scheduled Pinned Locked Moved ASP.NET
csharpdatabaseasp-netsql-serversysadmin
5 Posts 4 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.
  • R Offline
    R Offline
    roshid
    wrote on last edited by
    #1

    i am a beginner of asp.net2.0 and c#,i am storing an image(binary data)in a sql server 2005 db table,i want to display image to datalist please help me

    B N N 3 Replies Last reply
    0
    • R roshid

      i am a beginner of asp.net2.0 and c#,i am storing an image(binary data)in a sql server 2005 db table,i want to display image to datalist please help me

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      Duplicate post again?One will always suffice!!

      Cheers!! Brij

      1 Reply Last reply
      0
      • R roshid

        i am a beginner of asp.net2.0 and c#,i am storing an image(binary data)in a sql server 2005 db table,i want to display image to datalist please help me

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        You need to create a ASPX page which reads data from database and send response with image content type. Assume it's name is ShowImage.aspx. In your datalist, put template columns and specify the image tag like

        <img src="ShowImage.aspx">

        If you have to pass additional values to ShowImage.aspx, pass it through query string.

        Navaneeth How to use google | Ask smart questions

        R 1 Reply Last reply
        0
        • R roshid

          i am a beginner of asp.net2.0 and c#,i am storing an image(binary data)in a sql server 2005 db table,i want to display image to datalist please help me

          N Offline
          N Offline
          Nishant Singh
          wrote on last edited by
          #4

          http://www.netomatix.com/development/GridViewDisplayBlob.aspx[^] See if this could help you

          1 Reply Last reply
          0
          • N N a v a n e e t h

            You need to create a ASPX page which reads data from database and send response with image content type. Assume it's name is ShowImage.aspx. In your datalist, put template columns and specify the image tag like

            <img src="ShowImage.aspx">

            If you have to pass additional values to ShowImage.aspx, pass it through query string.

            Navaneeth How to use google | Ask smart questions

            R Offline
            R Offline
            roshid
            wrote on last edited by
            #5

            I used this code for datalist page load-frmCheck.aspx clsSqlHelp objHelp = new clsSqlHelp(); clsBllChek objBllCheck = new clsBllChek(); string imggrabFlag = "PF"; protected void Page_Load(object sender, EventArgs e) { objBllCheck.comboFill(cmbProduct); //objBllCheck.DataListFill(dlProduct); DatalistFill(); } protected void btnSearch_Click(object sender, EventArgs e) { } public void DatalistFill() { objHelp.openConnection(); DataSet objDs = new DataSet(); SqlDataAdapter objDa; string strSql; //strSql = "select imgId,imgData,imgTitle from checktabl"; strSql = "select prd_id,name,logo,logo_Length from Edms_Product_Mstr"; objDa = new SqlDataAdapter(strSql, objHelp.dbCon); objDa.Fill(objDs); objDs.Tables[0].Columns.Add("imgFile"); foreach (DataRow dt in objDs.Tables[0].Rows) { dt["imgFile"] = ("imgGrab.aspx?id=" + dt["prd_id"] + "&flag=" + imggrabFlag); int idc = Convert.ToInt32(dt["prd_id"]); } dlProduct.DataSource = objDs; dlProduct.DataBind(); objHelp.dbCon.Close(); } public string FormatURL(object strArgument) { int id = Convert.ToInt32(strArgument.ToString()); //return ("imgGrab.aspx?id=" + Convert.ToInt32(strArgument.ToString())); return ("imgGrab.aspx?id=" + Convert.ToInt32(strArgument.ToString()) + "&flag=" + imggrabFlag); } 2 also i used an another page imgGrab and write the code below protected void Page_Load(object sender, EventArgs e) { objHelp.openConnection(); int id = Convert.ToInt32(Request.QueryString["id"]); DataSet ds = new DataSet(); SqlDataAdapter da; byte[] arrContent; DataRow dr; string strSql=""; if (Request.QueryString["flag"].ToString() == "PF") { strSql = "Select * from edms_product_mstr Where prd_id='" + Request.QueryString["id"] + "'"; da = new SqlDataAdapter(strSql, objHelp.dbCon); da.Fill(ds); dr = ds.Tables[0].Rows[0]; arrContent = (byte[])ds.Tables[0].Rows[0][9]; string conType = ds.Tables[0].Rows[0][13].ToString(); Response.ContentType = conType; Response.OutputStream.Write(arrContent, 0, int.Parse(ds.Tables[0].Rows[0][11].ToString())); Response.End(); }

            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