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
close icon

Handling checkbox click in GridDataBoundGrid

One column of my databound gdbg is a checkbox. This column is a type bit column in the underlying datatable. When the checkbox is clicked, I want to test the value and if true, update a date in another column on the same row. I'm having trouble getting the value of the checkbox. Following is the code for the CheckBoxClick event:

private void gridLabs_CheckBoxClick(object sender, GridCellClickEventArgs e)
{
//Set complete date if Complete is checked
Int32 col1Idx;
Int32 col2Idx;
gridLabs.CurrentCell.MoveTo(e.RowIndex, e.ColIndex, GridSetCurrentCellOptions.SetFocus);
GridCurrentCell cc = gridLabs.CurrentCell;
col1Idx = gridLabs.Binder.NameToColIndex("testComplete");
col2Idx = gridLabs.Binder.NameToColIndex("dateTestCompleted");
if (e.ColIndex == col1Idx)
{
//TestComplete column
if (cc.Renderer.ControlText == "False")
{
//Test is complete
gridLabs[e.RowIndex, col2Idx].CellValue = DateTime.Now.ToShortDateString();
}
else
{
//Test is not complete; clear date
gridLabs[e.RowIndex, col2Idx].CellValue = DBNull.Value;
}
}

}


I'm sure there's a simple solution. Your help is greatly appreciated. Thanks in advance.

2 Replies

DG Dan Garvin October 25, 2006 12:49 AM UTC

Sorry. Forgot to point out that in the click event, I always get the checkbox value prior to clicking it. So, if it is unchecked and I check it, the .cellvalue or the .renderer.controltext give me "false" instead of the expected true. Thanks.


DG Dan Garvin October 25, 2006 01:33 PM UTC

I've opened a case in Direct-Trac. Thanks.

Loader.
Live Chat Icon For mobile
Up arrow icon