- Home
- Forum
- ASP.NET Web Forms (Classic)
- Edit a row in grid
Edit a row in grid
- Mar 28, 2012 04:50 PM UTC
- Apr 10, 2012 06:40 AM UTC
Hi,
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
SMitha
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
SMitha
SIGN IN To post a reply.
6 Replies
SN
Sridhar N
Syncfusion Team
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.
http://www.syncfusion.com/downloads/Support/DirectTrac/General/Editing1403998039.zip
Please refer the below link for online sample.
http://asp.syncfusion.com/demos/ui/gridgrouping/CRUD%20Operations/EditCellTypes/cs/EditCellType.aspx
Please let us know if any concerns.
Regards,
Sridhar N
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.
http://www.syncfusion.com/downloads/Support/DirectTrac/General/Editing1403998039.zip
Please refer the below link for online sample.
http://asp.syncfusion.com/demos/ui/gridgrouping/CRUD%20Operations/EditCellTypes/cs/EditCellType.aspx
Please let us know if any concerns.
Regards,
Sridhar N
SM
Smitha
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.
Thanks
Smitha
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.
Thanks
Smitha
SM
Smitha
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
MC
Mercy C
Syncfusion Team
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.
Regards,
Mercy.C
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.
Regards,
Mercy.C
SM
Smitha
April 5, 2012 04:20 PM UTC
Hi Mercy,
I am using windows forms+ grid control, C#
Smitha
I am using windows forms+ grid control, C#
Smitha
MC
Mercy C
Syncfusion Team
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.
Query3 : To Select rows, you can set "AllowSelection" flag to "Row". "AlphaBlendSelectionColor" gives the specified color to the selected row.
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.
Please refer to the sample in the following link
http://www.syncfusion.com/downloads/Support/DirectTrac/93095/WindowsFormsApplication811573917874.zip
Please let me know if you have any concerns.
Regards,
Mercy.C
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
http://www.syncfusion.com/downloads/Support/DirectTrac/93095/WindowsFormsApplication811573917874.zip
Please let me know if you have any concerns.
Regards,
Mercy.C
SIGN IN To post a reply.
- 6 Replies
- 3 Participants
-
SM Smitha
- Mar 28, 2012 04:50 PM UTC
- Apr 10, 2012 06:40 AM UTC