Another try:
1. Add this your GridView:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id"
DataSourceID="SqlDataSource1" OnRowCreated="GridView1_RowCreated1" >
<Columns>
<asp:TemplateField HeaderText="myRowid">
<ItemTemplate><asp:Label runat="server" />
</ItemTemplate>
</asp:TemplateField>
...
</Columns>
2. Add this to your code page
Protected Sub GridView1_RowCreated1(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If e.Row.RowType = DataControlRowType.DataRow Then
' Retrieve the Label from the first column.
Dim myLabel As Label = CType(e.Row.Cells(0).Controls(0), Label)
' Set Label text equal to the rowIndex +1
myLabel.Text = e.Row.RowIndex.ToString() + 1
End If
End Sub
Limno
Format your SQL query with instant sql formatter:
http://www.dpriver.com/pp/sqlformat.htm