Insus. NEt has written an article "Repeater control last record highlight". Its implementation is to first declare a page-level variable, and then in Data_Binding () method to obtain the total number of records of the data source.
The focus of this article is to change the Writing Method of the previous article. Instead of declaring a page-level variable, it is obtained directly in the OnItemDataBound event.
First read. aspx:
Go to. aspx. cs to write the code behind code:
The #35 lines of code in is to convert the sender object to the Repeater control.
#37 lines of code converts Rpt. DataSource to a DataTable object. Why should we convert it to a able object instead of a dataset of other types? The Repeater control is bound to a DataTable dataset in Data_Binding. Therefore, you must match the conversion result.
You still need to preview the webpage running effect: