Insus. NET has previously written "Repeater control first 10 records highlighted". However, there is an idea now that the last record is highlighted. How can this problem be achieved?
The technical requirement is to obtain the last index. You can subtract one record from the total record of the data source to obtain the index of the last Repeater control.
Create a Repeater control in the webpage and write the OnItemDataBound event.
Go to. aspx. cs to write the program:
#1 is to declare a total variable.
#2 is the DataTable of the data source to obtain the total number of records.
#3: determines whether the ItemIndex of the current Item is equal to one minus the total record. Why do we need to remove one? Because the index starts from 0. You do not need to subtract one from the total number, but add one to the Index, as shown below:
#4 is to get the ID set in Html --> "tr", and then add a style for its Attributes.
Webpage running effect: