I am trying to rewrite what the old controls did for the new controls and I am having some issues.
How do I loop through each row, is this correct?
foreach (GridRecord cRow in dgvPunchs.Rows)
{
Do something
}
How do I look through each cell within each row, is this correct?
Finally how do I see if each cell is of type checkbox? I set the value of the cell to "0" so each check box is unchecked. I don't use a check box control for this.
I was able to fix it, thank you for your help. :)
Hi OmegaPrime,
Are you still having issues after changing UnboundCheckBoxField to BoundCheckBoxField?
Let me know if you need any further assistance with the matter.
This is throwing an exception.
Unable to cast object of type 'Infragistics.Web.UI.GridControls.BoundDataField' to type 'Infragistics.Web.UI.GridControls.BoundCheckBoxField'.
I have 7 columns.
pDates.Columns.Add("Key"); pDates.Columns.Add("Date", System.Type.GetType("System.DateTime")); // Date Cell pDates.Columns.Add("Worked", System.Type.GetType("System.Boolean")); //Worked CB pDates.Columns.Add("Vaction", System.Type.GetType("System.Boolean")); //Vacation CB pDates.Columns.Add("Sick", System.Type.GetType("System.Boolean")); //Sick CB pDates.Columns.Add("Holiday", System.Type.GetType("System.Boolean")); //Holiday CB pDates.Columns.Add("Error", System.Type.GetType("System.String")); //Error
Any idea how to look through each row, then cell without it throwing the cast exception?
EDIT: I changed UnboundCheckBoxField to BoundCheckBoxField in my version as I changed everything to be bound fields.
You could iterate through rows and cells, and check if given cell is an UnboundCheckBoxField using code similar to the following:
foreach (GridRecord row in WebDataGrid1.Rows)
for (int i = 0; i < row.Items.Count; i++ )
if ((UnboundCheckBoxField)row.Items[i].Column != null)
//Do something
Please let me know if this helps.