# Update Grids by Using timestamp Property

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Telerik UI for ASP.NET MVC Grid</td>
 </tr>
 <tr>
  <td>Product version</td>
  <td>2025.1.227</td>
 </tr>
</table>

## Description

How can I update Grids by using `timestamp` property?

## Solution

You can achieve this requirement using the following implementation:

1. Create an editable Grid:

   ```Razor HtmlHelper
   @(Html.Kendo().Grid<Telerik.Examples.Mvc.Areas.GridTimestamp.Models.Product>()
       .Name("grid")
       .Columns(columns =>
       {
           columns.Bound(p => p.ProductID);
           columns.Bound(p => p.ProductName);
           columns.Bound(p => p.RowVersionString);
           columns.Command(command => command.Edit());
       })
       .DataSource(source =>
       {
           source.Ajax()
           .Model(model =>
           {
               model.Id(p => p.ProductID);
               model.Field(p => p.ProductID).Editable(false);
           })
           .Read("Read", "Home")
           .Update("Update", "Home");
       })
   )
   ```

2. Define the `timestamp` Model property:

   ```C#
   public class Product
   {
       [Key]
       [DatabaseGenerated(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity)]
       public int ProductID { get; set; }
       public string ProductName { get; set; }

       [Timestamp]
       public byte[] RowVersion { get; set; }

       [NotMapped]
       public string RowVersionString
       {
           get
           {
               if (this.RowVersion != null)
               {
                   return Convert.ToBase64String(this.RowVersion);
               }

               return string.Empty;
           }
           set
           {
               if (string.IsNullOrEmpty(value))
               {
                   this.RowVersion = null;
               }
               else
               {
                   this.RowVersion = Convert.FromBase64String(value);
               }
           }
       }
   }
   ```

3. Define the Update Action:

   ```C#
   public ActionResult Update(Product product)
   {
       if (ModelState.IsValid)
       {
           context.Products.Attach(product);
           context.Entry(product).State = EntityState.Modified;
           context.SaveChanges();
       }

       return Json(new[] { product }.ToDataSourceResult(new DataSourceRequest(), ModelState));
   }
   ```

To review the complete example, refer to the [project on how to update the Telerik UI Grid in ASP.NET MVC applications by using the `timestamp` property](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/Telerik.Examples.Mvc/Telerik.Examples.Mvc/Areas/GridTimestamp).

## More ASP.NET MVC Grid Resources

* [ASP.NET MVC Grid Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/grid/overview)
* [ASP.NET MVC Grid Demos](https://demos.telerik.com/aspnet-mvc/grid/index)
* [ASP.NET MVC Grid Product Page](https://www.telerik.com/aspnet-mvc/grid)
* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)
* [Telerik UI for ASP.NET MVC Forums](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [Client-Side API Reference of the Grid for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/grid)
* [Server-Side API Reference of the Grid for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/grid)
* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
