We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Edit a row in grid

Thread ID:





103079 Mar 28,2012 04:50 PM UTC Apr 10,2012 06:40 AM UTC ASP.NET Web Forms (Classic) 6
Tags: GridGroupingControl
Asked On March 28, 2012 04:50 PM UTC


Can someone help me the events req to edit, update a row in the grid control.

When the user selects a edit from the context menu, the rows should be editable


Sridhar N [Syncfusion]
Replied On March 29, 2012 11:57 AM UTC

Hi Smitha,

Thanks for your interest in Syncfusion products.

Query #1 “Can someone help me the events req to edit, update a row in the grid control.”

Considering your requirement is about GridGroupingControl, we provide the solution. Your requirement to edit the grid and to hook corresponding event is “DataSourceControlRowUpdating”. Please refer the below code snippet.

[Codebehind – C#]
protected void Page_Load(object sender, EventArgs e)
// Event Hook
this.GridGroupingControl1.DataSourceControlRowUpdating += new Syncfusion.Web.UI.WebControls.Grid.Grouping.GridDataSourceControlRowUpdateEventHandler(GridGroupingControl1_DataSourceControlRowUpdating);

//Event handler
void GridGroupingControl1_DataSourceControlRowUpdating(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.GridDataSourceControlRowUpdateEventArgs e)
e.Cancel = true;
e.Handled = true;

For your convenience, we have created sample and the same can be downloaded from the following link.


Please refer the below link for online sample.

Please let us know if any concerns.

Sridhar N

Replied On April 2, 2012 01:45 AM UTC

Hi Sridhar,

Thank you for the solution. But I am not using the grid grouping control,
I am using the grid control. This is achieve excel like functionality. The user can add cells, delete cells, add rows, delete rows, edit rows, select rows

Here's how far I got.
On selecting a cell and right click, the user should be able to add cells. I was able to a context menu for the right click.
But for adding cells functionality, I am not sure how to get the rowindex, colindex of the selected cell.
None of these seem to get the row/colindex
//int currentMouseOverColumn1 = theGrid.GridCellsRange.Left;
//int currentMouseOverRow1 = theGrid.GridCellsRange.Right;
// int currentMouseOverRow = theGrid.CurrentCell.RowIndex;
// int currentMouseOverColumn = theGrid.CurrentCell.ColIndex;

Also, when the user selects a cell, I want the cell to be hightlighted just like in excel.

Any help is appreciated.


Replied On April 2, 2012 01:47 AM UTC

Also, the online sample link doesnt seem to be working. It is giving me a runtime, web.config error

Mercy C [Syncfusion]
Replied On April 5, 2012 12:09 PM UTC

Hi Smitha,

Thanks for your interest in syncfusion products.

Please do let us know which platform you are using either Windows or Web so that we can provide solution accordingly.

Please do let me know if you have any concerns.


Replied On April 5, 2012 04:20 PM UTC

Hi Mercy,

I am using windows forms+ grid control, C#


Mercy C [Syncfusion]
Replied On April 10, 2012 06:40 AM UTC

Hi Smitha,

Thanks for your update.

Query 1: You can make use of "CurrentCellStartEditing" event to edit a cell.

Query2: You can insert, delete the rows using "InsertRange()" and "DeleteRange()" methods which is handled in "contextMenuStrip1_ItemClicked" event.

void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
row = 0;
col = 0;
this.gridControl1.PointToRowCol(p,out row, out col);
if (e.ClickedItem.ToString() == "Insert")
this.gridControl1.Rows.InsertRange(row, 1); //inserts 1 row before selected row

if (e.ClickedItem.ToString() == "Delete")
this.gridControl1.Rows.RemoveRange(row, row);// deletes the selected row

Query3 : To Select rows, you can set "AllowSelection" flag to "Row". "AlphaBlendSelectionColor" gives the specified color to the selected row.

this.gridControl1.AllowSelection = Syncfusion.Windows.Forms.Grid.GridSelectionFlags.Row | Syncfusion.Windows.Forms.Grid.GridSelectionFlags.AlphaBlend;
this.gridControl1.AlphaBlendSelectionColor = Color.Blue;

Query 4: To insert cells and delete cells, we dont have support.

Query 5: To highlight the borders of selected cells, please make use of "CellClick" and "CurrentCellControlLostFocus" events. Set the required border style in "CellClick" event and reset the border in "CurrentCellControlLostFocus" event.

void gridControl1_CellClick(object sender, Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs e)
style = this.gridControl1[e.RowIndex, e.ColIndex];
style.Borders.All = new GridBorder(GridBorderStyle.Solid, Color.Black, GridBorderWeight.ExtraThin);

if (e.RowIndex >= 1 && e.MouseEventArgs.Button == MouseButtons.Right)
this.contextMenuStrip1.Show(this.gridControl1, e.MouseEventArgs.Location);
p = e.MouseEventArgs.Location;

void gridControl1_CurrentCellControlLostFocus(object sender, ControlEventArgs e)
style.Borders.All = new GridBorder(GridBorderStyle.Standard);

Please refer to the sample in the following link

Please let me know if you have any concerns.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon