Bind RowVersion field to popup editor (byte[])

5 posts, 0 answers
  1. Ben
    Ben avatar
    4 posts
    Member since:
    Dec 2012

    Posted 21 Jan 2013 Link to this post

    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?
  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 23 Jan 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Jeremy
    Jeremy avatar
    5 posts
    Member since:
    Aug 2012

    Posted 16 Apr 2013 Link to this post

    I'm having the same issue.  Unfortunately, I don't understand this answer.  Could you provide some more detail?
  5. Beau
    Beau avatar
    19 posts
    Member since:
    Mar 2011

    Posted 27 Jun 2013 Link to this post

    Similar issue - how do you handle TimeStamp (rowversion) column when inline editing. The model passed to the Controller method is null.
  6. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 02 Jul 2013 Link to this post

    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!
Back to Top
Kendo UI is VS 2017 Ready