2 urgent problems with binary image column

3 posts, 0 answers
  1. ManniAT
    ManniAT avatar
    885 posts
    Member since:
    Nov 2003

    Posted 07 Feb 2010 Link to this post


    I have two problems with the BinaryImage Column.
    The first: how to use the thing with LInq? Shall I extend my Ling2Sql generated class to convert the image column to a format the BinaryImage column can handle? If so - how?
    By the way - the thing is around more than half a year - and can still not work with Linq directly?
    Not sooo important - it works when I bind to a SQL Source.

    The bigger problem. As I commented at this sample
    this is far away from reality. BUT - I guess this has something to with my problem.
    The sample forces the user always to upload an image. This may be OK on insert operations.
    But how about edit operations? The user made a mistake (typo) needs to change the text - and after the update the image is gone...

    Or think about "long term" data. The user uploads an image, adds text....
    After a longer period of time he has some additional information - and wants to add some text.
    Unfortunately he has no access to the uploaded image...
    Bad luck :)

    I guess my customer is a bit sad if I tell him:
    We will add an instruction like this:
    You can only edit textual content when you can provide an image to upload. :)

    To be clear:
    I have a (if possible with the BinaryImage Column) Linq Datasource with an image (later there will be 2 images) and some text / date / number fields.
    The user must be able to:
    a.) Add a record with (or without) an image
    --is there a simple way to provide a "No image" display?
    b.) Edit a record without uploading a new (the old) image

    That's all.

    Thanks in advance
  2. ManniAT
    ManniAT avatar
    885 posts
    Member since:
    Nov 2003

    Posted 08 Feb 2010 Link to this post

    Just a little update.
    Since this is urgent I messed around a bit and thought about handling images in a popup.
    So I wanted Grid only to display the current image.

    To achive this I set the image field to ReadOnly=true.
    Anyhow - editing a row clears the image :(

  3. Veli
    Veli avatar
    2002 posts

    Posted 11 Feb 2010 Link to this post

    Hi ManniAT,

    The fact that the demo you are referring to does not allow a record to be updated without re-uploading an image doesn't mean that you cannot implement a scenario in which file upload can be skipped on edit.

    When RadGrid is updating, you can check if there is any file uploaded with the updated item. If no file was uploaded, you can skip modifying the data field holding the binary image data.

    Additionally, the GridBinaryImageColumn.DefaultImageUrl property is used to show a default image (in this case a noimage indicator) if no binary image can be retrieved from RadGrid's data source.

    As for LINQ, it's true that GridBinaryImageColumn does not currently support the default data type that is generated by the ORM designer for binary fields (System.Data.Linq.Binary). Therefore, you need to modify your data classes and specify that the binary data field should be of type byte[] instead. In terms of the ORM designer, you have to right-click on the field name, select Properties and choose byte[] for the data type.

    Attaching a sample project you can test locally. It's got 2 pages - 1 with SqlDataSource, and another with LinqDataSource and data classes. In both cases, the image data is modified only if there is any data uploaded. For LINQ, this logic is implemented in the Image binary data property setter:

    [Column(Storage = "_Data", DbType = "Image", UpdateCheck = UpdateCheck.Never)]
        public byte[] Data
                return this._Data;
                //if ((this._Data != value))
                if ((this._Data != value) && value != null && value.Length > 0)
                    this._Data = value;

    You can check it out.

    Kind regards,
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Back to Top