Hello
Is there a way to check if a cell in a DataRecord exists? I have the following code:
void grid_InitializeRecord(object sender, Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs e) { if (e.Record is DataRecord) { DataRecord dr = (DataRecord)e.Record; try { dr.Cells["No."].Value = (e.Record.Index + 1).ToString(); } catch (Exception ex) { } } }
and I want to remove the try/catch and replace it with something like
if (dr.Cells["No."].Exists) { }
Is there any way to do this?
Many thanks
Kostas.
This is a pretty old post, but I've run into the same question. Since catching an exception gets really noisy when debugging with "break when exceptions are thrown" enabled, I wanted to get rid of the possible exception that could be thrown. This appears to do that:
Shared Function GetDataRecordCell(dataRecord As DataRecord, cellName As String) As Cell Contract.Requires(dataRecord IsNot Nothing) Contract.Requires(Not String.IsNullOrWhiteSpace(cellName)) Dim cell = dataRecord.Cells.SingleOrDefault(Function(c) c.Field.Name = cellName) Return cell End Function
And it's used like this:
Dim statusCell = GetDataRecordCell(dr, "Status") If statusCell Is Nothing Then Return Binding.DoNothing Dim status As String = statusCell.Value
I also need similar functionality. Please help
Anyone from Infragistics can suggest a solution?
Kostas