This is a migrated thread and some comments may be shown as answers.

Retrieve image from Database

2 Answers 228 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Eduardo
Top achievements
Rank 1
Eduardo asked on 20 Dec 2011, 02:18 AM
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 Answers, 1 is accepted

Sort by
0
Eduardo
Top achievements
Rank 1
answered on 20 Dec 2011, 04:22 AM
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?
0
Rumen
Telerik team
answered on 22 Dec 2011, 06:12 PM
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
Tags
ImageEditor
Asked by
Eduardo
Top achievements
Rank 1
Answers by
Eduardo
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or