It is really unclear what you are trying to achieve so here are a few suggestions
1. IF you are trying to add a row number column to the Gridview then it is as simple as including the following snippet in your gridview definition
<asp:TemplateField HeaderText="ID" >
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>
You may have to change the calculation if you want the row number reversed. This suggestion is all over the Internet, which you can find by using the search term
Search for:
asp net gridview label row number
Note that this will always show the GridView row number
2. IF you are trying to assign a row number to the SQL results that you are binding to, then you can use the
ROW_NUMBER (Transact-SQL) - SQL Server | Microsoft Docs[
^] function. Note this will always show the row number as returned even if you sort the GridView