Refer the below sample code for your reference and implement the same logic as per your code to get row number. Just check the GetRowNo method functionality that only you need to impliment in your code.
Here i am making use of Northwind database.
SQL
CREATE PROCEDURE [dbo].[GetCustomersDetails]
AS
BEGIN
SET NOCOUNT ON;
SELECT Top 10
[CustomerId]
,[City]
,[ContactName]
,[Country]
,[PostalCode]
,[Phone]
,[Fax]
,[CompanyName]
FROM [Customers]
END
GO
HTML
<%@ Register Assembly="CollectionPager" Namespace="SiteUtils" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
.Repeater, .Repeater td, .Repeater td
{
border: 1px solid #ccc;
}
.Repeater td
{
background-color: #eee !important;
}
.Repeater th
{
background-color: #6C6C6C !important;
color: White;
font-size: 10pt;
line-height: 200%;
}
.Repeater span
{
color: black;
font-size: 10pt;
line-height: 200%;
}
.page_enabled, .page_disabled
{
display: inline-block;
height: 20px;
min-width: 20px;
line-height: 20px;
text-align: center;
text-decoration: none;
border: 1px solid #ccc;
}
.page_enabled
{
background-color: #eee;
color: #000;
}
.page_disabled
{
background-color: #6C6C6C;
color: #fff !important;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<br />
<br />
<table width="500" border="1" align="center">
<tr>
<td class="auto-style1">
S. No
</td>
<td class="auto-style1">
Soyadı
</td>
<td class="auto-style1">
Adı
</td>
<td class="auto-style1">
Borcu
</td>
<td align="center">
Sil
</td>
</tr>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<tr>
<td>
<%# GetRowNo(Convert.ToString(Container.ItemIndex + 1))%>
</td>
<td>
<%# Eval("CustomerId")%>
</td>
<td>
<%# Eval("CustomerId")%>
</td>
<td align="right">
<%# Eval("CompanyName")%>
TL
</td>
<td>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
<br />
<center>
<cc1:CollectionPager ID="CollectionPager1" runat="server" PageSize="3" BackText="&nbsp;«Önceki"
FirstText="İlk Sayfa" LabelText="Sayfa :&nbsp;" LastText="Son Sayfa" NextText=" Sonraki»"
ResultsFormat="(Toplam {2} veriden {0}-{1} arası veri görüntülenmektedir.)">
</cc1:CollectionPager>
</center>
</form>
</body>
</html>
C#
public int PageIndex
{
get { return ViewState["PageIndex"] != null ? (int)ViewState["PageIndex"] : 1; }
set { ViewState["PageIndex"] = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.GetCustomersDetails();
}
}
protected string GetRowNo(string itemIndex)
{
int pageindex = 1;
int.TryParse(Request.QueryString["Page"], out pageindex);
return pageindex > 1 ? (((pageindex - 1) * CollectionPager1.PageSize) + Convert.ToInt32(itemIndex)).ToString() : itemIndex;
}
private void GetCustomersDetails()
{
string constring = ConfigurationManager.ConnectionStrings["constring"].ConnectionString;
SqlConnection con1 = new SqlConnection(constring);
SqlCommand cmd1 = new SqlCommand("GetCustomersDetails", con1);
cmd1.CommandType = CommandType.StoredProcedure;
con1.Open();
SqlDataReader dr = cmd1.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(dr);
CollectionPager1.DataSource = dt.DefaultView;
CollectionPager1.BindToControl = Repeater1;
Repeater1.DataSource = CollectionPager1.DataSourcePaged;
Repeater1.DataBind();
con1.Close();
CollectionPager1.PageSize.ToString();
}
VB.Net
Public Property PageIndex As Integer
Get
Return If(ViewState("PageIndex") IsNot Nothing, CInt(ViewState("PageIndex")), 1)
End Get
Set(ByVal value As Integer)
ViewState("PageIndex") = value
End Set
End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Me.GetCustomersDetails()
End If
End Sub
Protected Function GetRowNo(ByVal itemIndex As String) As String
Dim pageindex As Integer = 1
Integer.TryParse(Request.QueryString("Page"), pageindex)
Return If(pageindex > 1, (((pageindex - 1) * CollectionPager1.PageSize) + Convert.ToInt32(itemIndex)).ToString(), itemIndex)
End Function
Private Sub GetCustomersDetails()
Dim constring As String = ConfigurationManager.ConnectionStrings("constring").ConnectionString
Dim con1 As SqlConnection = New SqlConnection(constring)
Dim cmd1 As SqlCommand = New SqlCommand("GetCustomersDetails", con1)
cmd1.CommandType = CommandType.StoredProcedure
con1.Open()
Dim dr As SqlDataReader = cmd1.ExecuteReader()
Dim dt As DataTable = New DataTable()
dt.Load(dr)
CollectionPager1.DataSource = dt.DefaultView
CollectionPager1.BindToControl = Repeater1
Repeater1.DataSource = CollectionPager1.DataSourcePaged
Repeater1.DataBind()
con1.Close()
CollectionPager1.PageSize.ToString()
End Sub
Screenshot
