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. Image for the cookie policy date

CheckBoxClick event or CurrentCellChanged event

Here is the scenario and I am not sure which event (CheckBoxClick or CurrentCellChanged) is the right one to use. I have a grid control that has two check boxes. These check boxes suppose to do totally different things. When click in one of them it suppose to display two hidden columns and the other one suppose to change some coloring. CheckBoxClick event is for grid therefore I need to know which checkbox has changed to do the proper action. I thought of CurrentCell.RowIndex and CurrentCell.ColIndex. But for first time when I click on the checkbox the RowIndex and ColIndex returns -1, -1. The second time it returns the correct position. How can I fix this? Should I use CurrentCellChanged instead?

7 Replies

AD Administrator Syncfusion Team August 30, 2005 03:21 PM UTC

What kind of grid are you using? Why can you not use gridControl1.CheckBoxClick or gridGroupingControl1.TableControlCheckBoxClick or gridDataBoundGrid1.CheckBoxClick?

NJ Najmeh Joze-khajavi August 30, 2005 05:08 PM UTC

I am using GridControl. When I said CheckBoxClick event I meant the same as gridControl1.CheckBoxClick. Since I have two check boxes I need to know which checkbox has been checked by user. Therefore I need to know the row and column of the checkbox. I found out how I can get the row and column. I used e.RowIndex and e.ColIndex. private void _WorksheetGrid_CheckBoxClick(object sender, GridCellClickEventArgs e) { GridStyleInfo style; GridControl grid = sender as GridControl; if (grid != null) { if (e.RowIndex == 1 && e.ColIndex ==5 ) //Show Prefault { .... } if (e.RowIndex == 14 && e.ColIndex == 11 ) { ... } ... }

RA ralph_lachance November 29, 2005 09:57 PM UTC

Actually, Clay, Najmeh''s question raises an important question - is there something broken about the CurrentCellChanged event w/r/t checkboxes?? Inside that event, I am seeing what seems to be inconsistent behavior. If the cell firing the event is a textbox, grid.CurrentCell().GetRenderer().GetCellValue() returns the correct "new value" in the text box. If, however, the cell that changed is a checkbox, GetRenderer().GetCellValue() ~always~ returns true. Could this be correct?

AD Administrator Syncfusion Team November 30, 2005 12:45 AM UTC

This is actually by design. The CheckBox CellType is special. It has no active cell control and the checkbox is drawn in a static manner. There is no Control used to render this cell. The values are immediately stored in the grid as they are changed. Here is code that shows how to get this current value in CurrentCellChanged.
private void gridControl1_CurrentCellChanged(object sender, EventArgs e)
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	if(this.gridControl1[cc.RowIndex, cc.ColIndex].CellType == "CheckBox")
		Console.WriteLine(this.gridControl1[cc.RowIndex, cc.ColIndex].CellValue);

RA ralph_lachance November 30, 2005 11:11 PM UTC

Clay, Thanks for confirming this behavior is by design. I had already figured out to use grid[r,c].cellvalue - but I wasn''t sure this was by intent, or just a convenient hack. -ralph

GU Guadalupe March 27, 2019 07:26 PM UTC


Is possible the use of currentcell in asp.net?
I can't use this element.

Cordially, Guadalupe Baigorria

VN Vignesh Natarajan Syncfusion Team March 28, 2019 11:11 AM UTC

Hi Guadalupe, 
Thanks for using Syncfusion products. 
From your query, we are able to understand that you want to find the row and cell information in the server side when the checkbox cell is clicked in the grid. To achieve your requirement we suggest you to use the OnServerRecordClick event. 
Refer the below code example, 
<asp:UpdatePanel runat="server"> 
            <script id="template" type="text/template"> 
                <input type="checkbox" id="Verified{{:EmployeeID}}" name="Verified" onchange="myFunction(event)"  class="e-field e-checkbox" style="width: 30px" /> 
            <ej:Grid ID="EmployeesGrid" runat="server" AllowPaging="True" OnServerRecordClick="EmployeesGrid_ServerRecordClick"> 
                <PageSettings PageSize="4"></PageSettings> 
                <ClientSideEvents ActionComplete="Complete" /> 
                    <ej:Column HeaderText="checkbox" Template="#template" TextAlign="Center" Width="110" /> 
     var id, state; 
                function myFunction(event) { 
                    id = $(event.target).attr("id"); 
                    state = $(event.target).prop("checked"); 
                function Complete(args) { 
                    setTimeout(function () { 
                         $("#" + id).prop("checked", state); 
    protected void EmployeesGrid_ServerRecordClick(object sender, GridEventArgs e) 
            // do your stuff here. 
If we misunderstood, your requirement please get back to us with the following details. 
  1. Share the complete grid code example you are using.
  2. Share your requirement in detail.
Vignesh Natarajan. 

Live Chat Icon For mobile
Up arrow icon