Two methods for adding serial numbers to DataGrid

xiaoxiao2021-03-06  40

Two methods for adding serial numbers to DataGrid

??? When you display a DataGrid on the page, you often need to display a sequence, as shown in the figure:

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

• The corresponding changes have also occurred according to the filtering conditions of DataGrid.

??? In addition to creating views directly in the database, we can also use the methods described below:

??? Solution 1:

??? First,

Add in the label:

OnItemDatabaseD = "DataGrid_ItemDatabase", and

Add corresponding columns, such as:

??? Then join in CodeBehinde:

?? Sub DataGrid_itemdatabase (Byval E AS DataGriditeMeventArgs) ?????? if E.Item.itemType <> ListiteMTYPE.HEADER TEN ?????????? E.Item.cells (0 ) .Text = (E.Item.itemindex 1) .tostring "?????? end if ?? End Sub

??? Note: E.Item.cells (0) represents you want to display in the session, this example is displayed in the first column.

??? Solution 2:

???

Add:

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

??????????

??????????

Serial number

??????????

<% # Container.DatasetIndex 1%>

??????????

<% # Container.DatasetIndex 1%>

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

转载请注明原文地址:https://www.9cbs.com/read-74577.html

New Post(0)