Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7932089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:54:39+00:00 2026-06-03T20:54:39+00:00

I have two functions: Function 1: ImageToByteArray: Is used to Convert an Image into

  • 0

I have two functions:

Function 1: ImageToByteArray: Is used to Convert an Image into a Byte Array and then Store in an Oracle Database, in a BLOB Field.

            public byte[] ImageToByteArray(string sPath)
            {
                byte[] data = null;
                FileInfo fInfo = new FileInfo(sPath);
                long numBytes = fInfo.Length;
                FileStream fStream = new FileStream(sPath, FileMode.Open, FileAccess.Read);
                BinaryReader br = new BinaryReader(fStream);
                data = br.ReadBytes((int)numBytes);
                return data;
            }

Function 2: ByteArrayToImage: Is used to Convert a Byte Array from the Database into an Image:

           public System.Drawing.Image ByteArrayToImage(byte[] byteArray)
            {
                MemoryStream img = new MemoryStream(byteArray);
                System.Drawing.Image returnImage = System.Drawing.Image.FromStream(img);
                return returnImage;
            }

In my Markup I have an Imgage Control:
<asp:Image ID="Image1" runat="server" />

In the Code Behind I want to Assign the Returned Value from Function 2 to (which is of type System.Drawing.Image) to the “image1” control which is of type (System.Web.UI.WebControls.Image).

Obviously I can’t just assign:
image1 = ByteArrayToImage(byteArray);
because I’d get the following error: Cannot implicitly convert type ‘System.Drawing.Image’ to ‘System.Web.UI.WebControls.Image’

Is there anyway to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:54:41+00:00Added an answer on June 3, 2026 at 8:54 pm

    You can’t. WebControls.Image is just a HTML container for an image url – you can’t store the image data directly in it, you just store the reference (url) to an image file.

    If you need to retrieve image data dynamically, the usual approach is to create an image handler that will handle the request and return the image as a stream that the browser can display.

    See this question

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two functions. The first function translates a div click into a checked/unchecked
I have two functions. One Insert into database. It opens the connection and closes
i have two functions, the parent function is __triggerAction, than child function is __triggerNormal
Say I have two functions that expect ...rest parameters private function a(...myParams):void { trace(myParams.length);
I have two functions in an ActionScript class, they are: private function loaderCompleteHandler(event:Event):void {
I have two functions hooked on the submit event of a form. Each function
I have two Python functions, both of which take variable arguments in their function
Assuming I have the following two JQuery functions - The first, which works: $(#myLink_931).click(function
I have two functions here say animation1 and load1 they work like that: function
I have two functions, one which parses all the arguments sent to the function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.