---
title: "Grid control and data binding in WPF"
published_at: "2012-07-05T15:35:00+00:00"
modified_at: "2025-04-23T11:12:28+00:00"
url: "https://www.syncfusion.com/blogs/post/grid-control-and-data-binding-in-wpf"
excerpt: "The GridData control from Syncfusion was built for data binding applications. But, sometimes you need the flexibility of our Grid control. Here is a simple sample showing how you can implement basic data binding and updating via our Grid control...."
taxonomy_category:
  - "Grid"
  - "WPF"
taxonomy_post_tag:
  - "data binding"
  - "Grid"
  - "GridData"
  - "WPF"
---

# Grid control and data binding in WPF

[Chad Church](https://www.syncfusion.com/blogs/author/chadc)

![Image](https://www.syncfusion.com/blogs/wp-content/uploads/2018/08/grid_databinding_7d9ce375.png)


The GridData control from Syncfusion was built for data binding applications. But, sometimes you need the flexibility of our Grid control. Here is a simple sample showing how you can implement basic data binding and updating via our Grid control.

In this sample, we are handling the cell editing complete event to update the data source with a very simple validation check.

Download the sample [here](https://www.syncfusion.com/downloads/Support/DirectTrac/95955/SFWpfGridControl_AddNewRow1947623500.zip)
.

```
 void grid_CurrentCellEditingComplete(object sender, Syncfusion.Windows.ComponentModel.SyncfusionRoutedEventArgs args)
        {
            if (vm.Table.Rows.Count < this.grid.Model.RowCount - 1)
            {
                vm.Table.Rows.Add(vm.Table.NewRow());
            }
            int rowIndex = this.grid.CurrentCell.RowIndex;
            int colIndex = this.grid.CurrentCell.ColumnIndex;
            if (colIndex == 1)
                vm.Table.Rows[rowIndex - 1][colIndex] = this.grid.Model[rowIndex, colIndex].CellValue.ToString();
            else if (colIndex == 2 || colIndex == 0)
            {
                if (!this.grid.Model[rowIndex, colIndex].CellValue.ToString().IsNumeric())
                {
                    this.grid.Model[rowIndex, colIndex].CellValue = "0";
                }
                vm.Table.Rows[rowIndex - 1][colIndex] = int.Parse(this.grid.Model[rowIndex, colIndex].CellValue.ToString());
            }
        } 
```
