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

Using GetRecordStateAtRowIndex in PrepareViewStyleInfo

I am attempting to use the code below in the PrepareViewStyleInfo to obtain the DataRow so that I may prepare how my GDBG is to look. The 1st and second rows will be retrieved properly, but the 3rd row and up all come back as the 2nd row. Any help would be appreciated. Thanks, Virgil Dim Row As DataRow Dim PartType As String Dim RecordState As GridBoundRecordState = _Grid.Binder.GetRecordStateAtRowIndex(e.RowIndex) Dim o As Object = RecordState.ListManager.Current Dim drv As DataRowView = CType(o, DataRowView) Row = drv.Row PartType = Row(ColumnNames.BaseQuoteData.PartType)

4 Replies

AD Administrator Syncfusion Team April 13, 2005 12:42 AM UTC

The row being drawn is not always the current record. It is only the record at e.RowIndex which may or may not be Current. Try: Dim drv As DataRowView = RecordState.Table(RecordState.Position)


VI Virgil April 13, 2005 03:50 PM UTC

Tha worked Clay. Thanks.


VI Virgil April 15, 2005 12:08 PM UTC

Clay, The code you provided works well except in the case of a new row. When mousing over the row, the following error is thrown (row #32 is the new row). An unhandled exception of type ''System.IndexOutOfRangeException'' occurred in system.data.dll Additional information: Index 32 is not non-negative and below total rows count.


AD Administrator Syncfusion Team April 15, 2005 12:14 PM UTC

Before trying to use it, check for valid values like RecordState.Position > -1 && RecordState.Position < RecordState.Table.Count Or, you could check e.RowIndex < grid.Model.RowCount. The AddNew row does not have a record associated with it until it is actually added.

Loader.
Up arrow icon