GirdView Export To Image File RRS feed

  • Question

  • User-1222711838 posted

    Hi Guys any Idea how to Export A Gridview result to an Image file (such as jpeg or Bitmap file) ?


    Thanks In advance 

    Saturday, October 14, 2006 3:52 AM

All replies

  • User300685930 posted

    when you say gridview result, I usually have images in the gridview with img tags so the gridview never actually sees the jpg.  You can certainly use code like the following to extract a jpg from an assembly.  The code I'm pasting below is an HttpHandler that gets the Image data and then displays it like an img tag.


     public class CaptchaTypeHandler : IHttpHandler
            public void ProcessRequest(HttpContext context)
                if (context.Request.QueryString["encryptedvalue"] == null)
                    // likely, this is in design mode and we want to just show the
                    // default image for type 2.
                    Assembly assembly = Assembly.GetExecutingAssembly();
                    Stream imgStream =
                    byte[] ba = new byte[imgStream.Length];
                    imgStream.Read(ba, 0, Convert.ToInt32(imgStream.Length));

    Saturday, October 14, 2006 3:15 PM
  • User-1222711838 posted

    Thanks Peter ,

    Actually The code you wrote was useful , But I mean I want to Export a Gridview , Just Like Report or something . I mean I want to see the Resultset of a grid in an Image File , Do you Think is that Really Possible ? I want to Fax The Grid Search Result


    Thanks in advance 

    Sunday, October 15, 2006 6:34 AM
  • User2128074059 posted

    You can use DrawLine method to draw some grids like the source data table by yourselft, then save the image and fax it.

    Tuesday, October 17, 2006 10:38 PM