Retrieve image from Database

3 posts, 0 answers
  1. Eduardo
    Eduardo avatar
    7 posts
    Member since:
    Jul 2011

    Posted 19 Dec 2011 Link to this post

    Hi guys,

    I'm using RadImageEditor inside a FormView and i'm trying to retrieve a imagem from a Postgre Database. I'm also using OpenAccessDataSource.

    I follow this http://demos.telerik.com/aspnet-ajax/imageeditor/examples/default/defaultcs.aspx and this http://www.telerik.com/community/forums/aspnet-ajax/image-editor/combine-imageeditor-control-with.aspx links and i'm still not able to solve the issue.

    In my aspx page i have the following code:

    <telerik:RadImageEditor ID="RadImageEditor1" runat="server"  OnImageLoading="RadImageEditor1_ImageLoading" Width="720px" Height="430px">
    </telerik:RadImageEditor>

    In code behind i have the following:

    protected void RadImageEditor1_ImageLoading(object sender, ImageEditorLoadingEventArgs args)
    {
        DATA db = new DATA();
        var r = (from a in db.Tb_example where a.example_id == Convert.ToInt64(frmExample.DataKey.Value) select a).FirstOrDefault();
        if (r.Image != null)
        {
            MemoryStream s = new MemoryStream(r.Image.ToArray());
            Telerik.Web.UI.ImageEditor.EditableImage img = new Telerik.Web.UI.ImageEditor.EditableImage(s);
         args.Image = img;
         args.Cancel = true;
        }
    }

    I'm getting the following error message:

    "Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object."

    I'm sure the image is in the Database because i'm able to see it through RadBinaryImage control.

    Any help will be appreciated. Thanks in advance.
      
  2. Eduardo
    Eduardo avatar
    7 posts
    Member since:
    Jul 2011

    Posted 19 Dec 2011 Link to this post

    I did the following changes and the RadImageEditor began to work:

    - I removed the RadImageEditor from within the FormView;

    - I updated the version of Telerik Controls.

    But it would be much better if i could maintain the RadImageEditor inside the FormView. Is that possible?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rumen
    Admin
    Rumen avatar
    12849 posts

    Posted 22 Dec 2011 Link to this post

    Hi,

    How exactly did you bind the FormView: do you use some datasource control or you bind it programmatically?
    You can call the DataBind method of the FormView in the Page_Load event. If the FormView is bind on PreRender this will be late and the ImageEditor will not render the image and throw the mentioned error.

    If you are unable to solve the issue, please isolate it in a sample working project and send it for examination via a support ticket.

    Best regards,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top