My requirement is to show Serial No. in a descending order(10,9,8.....) in Gridview

<ItemTemplate>
     <asp:Label ID="lblsr" runat="server" />
</ItemTemplate>

I did it code behind but in case of Page Index, it again start from total number

Public count As Integer = 0        'Declared  as public

count = result.Count               ' Here I get total no. of rows or records

In below RowDataBound event it's decremented one each time

 Protected Sub gv_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvStaffMember.RowDataBound
    If e.Row.RowType = DataControlRowType.DataRow Then

        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim lblSerial As Label = DirectCast(e.Row.FindControl("lblsr"), Label)
            lblSerial.Text = count.ToString()
        End If
        count -= 1

    End If
End Sub

Related posts

Recent Viewed