This is a migrated thread and some comments may be shown as answers.

Detecting BOF & EOF in the itemdatabound event

3 Answers 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andy Green
Top achievements
Rank 2
Andy Green asked on 03 Dec 2015, 04:20 PM

Hi

Is it possible to detect the first and last records while in the itemdatabound event - I need to handle the display for these t rows.

Andy

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 08 Dec 2015, 09:21 AM
Hi Andy,

Checking if the current record is the last would require custom implementation that would depend on how you are binding the grid. For example, if you are using a DataTable to pass data to the RadGrid you can check if the index of the current item is equal to the number of items in the DataTable collection.

With that said, if you would like to change the styles for the first and last items in the grid you can use CSS. The following rules set the background color for the first and last items in the grid.


.rgMasterTable>tbody tr:first-child {
    background-color: red;
}
 
.rgMasterTable>tbody tr:last-child {
    background-color: red;
}


Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Andy Green
Top achievements
Rank 2
answered on 08 Dec 2015, 11:27 AM

Thanks Viktor

I have solved this the following way:

In the ItemDataBound for the first row:

If e.Item.ItemIndex = 0 Then
    'Do stuff
End If

For the last row:

If e.Item.DataSetIndex = e.Item.OwnerTableView.DataSourceCount - 1 Then
   'Do Stuff
End If

 Might help others in my position.

Andy

0
Viktor Tachev
Telerik team
answered on 08 Dec 2015, 11:57 AM
Hello Andy,

Thank you for sharing your solution with the community.

Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Andy Green
Top achievements
Rank 2
Answers by
Viktor Tachev
Telerik team
Andy Green
Top achievements
Rank 2
Share this question
or