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

Bind RowVersion field to popup editor (byte[])

4 Answers 229 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 21 Jan 2013, 07:11 AM
I have a need to allow the user to chose what action to take when a concurrency error occurs, I'm wondering how exactly I'd bind a RowVersion column to the Grid popup editor so it posts the timestamp back to my MVC action method? I was hoping I'd be able to simply designate it as a string in the data source model schema but I'm getting the error "The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters."

Has anyone else run into this issue? How did you resolve it? I'm guessing that javascript appends a "\0" when it converts the byte array to a string, so I (think) the work-around is to strip off the terminator character and convert the string back to a byte array in the grids...Save event?

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 23 Jan 2013, 09:54 AM
Hello Ben,

It should not be necessary to bind the field in the popup but automatic conversion to string will not work. You should convert the array explicitly.

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jeremy
Top achievements
Rank 1
answered on 16 Apr 2013, 04:46 PM
I'm having the same issue.  Unfortunately, I don't understand this answer.  Could you provide some more detail?
0
Beau
Top achievements
Rank 1
answered on 28 Jun 2013, 04:37 AM
Similar issue - how do you handle TimeStamp (rowversion) column when inline editing. The model passed to the Controller method is null.
0
Daniel
Telerik team
answered on 02 Jul 2013, 10:13 AM
Hello,

Basically, you should include a property in your ViewModel that keeps the byte array as a Base64 string so that it can be correctly bound on the server:

public byte[] row_version
{
    get;
    set;
}
 
public string RowVersion
{
    get
    {
        if (this.row_version != null)
        {
            return Convert.ToBase64String(this.row_version);
        }
 
        return string.Empty;
    }
    set
    {
        if (string.IsNullOrEmpty(value))
        {
            this.row_version = null;
        }
        else
        {
            this.row_version = Convert.FromBase64String(value);
        }
    }
}

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Ben
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Jeremy
Top achievements
Rank 1
Beau
Top achievements
Rank 1
Share this question
or