Dim cn As New SqlClient.SqlConnection(Me.GSqlCon)
Dim cmd As New SqlClient.SqlCommand("select * from (select row_number() over (order by Username) as Number,* from Table_User)Table_User where [Type]='User' ", cn)
Dim DA As New SqlClient.SqlDataAdapter(cmd)
Dim DT As New DataTable
DA.Fill(DT)
Dim S1 As New StringBuilder
For Each dr As DataRow In DT.Rows
S1.Append("<tr>")
S1.Append("<td>" & dr("Username") & "</td>")
S1.Append("<td>" & dr("name") & "" & dr("SurName") & "</td>")
S1.Append("<td>" & dr("Position") & "</td>")
S1.Append("<td>")
S1.Append("<button class='btn btn-primary btn-xs'>")
S1.Append("<i class='fa fa-pencil'>")
S1.Append("</i>")
S1.Append("</button>")
S1.Append("</td>")
S1.Append("<td>")
S1.Append("<button class='btn btn-danger btn-xs'>")
S1.Append("<i class='fa fa-trash-o'>")
S1.Append("</i>")
S1.Append("</button>")
S1.Append("</td>")
S1.Append("</tr>")
Next
Return S1.ToString
Imports System.Data
Imports System.Data.SqlClient
Public Class Index_Data_Admin
Inherits PFPPagesec
Dim con As New SqlConnection(Me.GSqlCon)
Dim str As String
Dim com As SqlCommand
Dim sqlda As SqlDataAdapter
Dim ds As DataSet
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack() Then
page_length.Text = "20"
start_page.Text = "0"
bindlist()
End If
End Sub
Public Sub First_record(ByVal s As Object, ByVal e As EventArgs)
start_page.Text = "0"
bindlist()
End Sub
Public Sub Previous_record(ByVal s As Object, ByVal e As EventArgs)
start_page.Text = CStr(CInt(start_page.Text) - CInt(page_length.Text))
If CInt(start_page.Text) < 0 Then
start_page.Text = "0"
End If
bindlist()
End Sub
Public Sub Next_record(ByVal s As Object, ByVal e As EventArgs)
If CInt(start_page.Text) + 1 < CInt(count_data.Text) Then
start_page.Text = CStr(CInt(start_page.Text) + CInt(page_length.Text))
End If
bindlist()
End Sub
Public Sub Last_record(ByVal s As Object, ByVal e As EventArgs)
Dim i As Integer
i = CInt(count_data.Text) Mod CInt(page_length.Text)
If i > 0 Then
start_page.Text = CStr(CInt(count_data.Text) - i)
Else
start_page.Text = CStr(CInt(count_data.Text) - CInt(page_length.Text))
End If
bindlist()
End Sub
Sub bindlist()
con.Open()
str = "select * from V_USER where Type='ADMIN' order by Username asc "
sqlda = New SqlDataAdapter(str, con)
ds = New DataSet()
If Not Page.IsPostBack() Then
sqlda.Fill(ds)
count_data.Text = CStr(ds.Tables(0).Rows.Count)
End If
sqlda.Fill(ds, CInt(start_page.Text), CInt(page_length.Text), "V_USER")
datalist_paging.DataSource = ds
datalist_paging.DataMember = "V_USER"
datalist_paging.DataBind()
con.Close()
navigate()
End Sub
Private Sub navigate()
'lblshow.ForeColor = Drawing.Color.Tomato
'lblshow.BackColor = Drawing.Color.Yellow
lblshow.Text = "จำนวน " & count_data.Text
lblshow.Text += " รายการ - Page :<b> "
lblshow.Text += CStr(CInt(CInt(start_page.Text) / CInt(page_length.Text) + 1))
lblshow.Text += "</b> of <b>"
If (CInt(count_data.Text) Mod CInt(page_length.Text)) > 0 Then
lblshow.Text += CStr(CInt(CInt(count_data.Text) / CInt(page_length.Text) + 1))
Else
lblshow.Text += CStr(CInt(count_data.Text) / CInt(page_length.Text))
End If
lblshow.Text += "</b>"
End Sub
End Class
Public Shared Function getRows(ByVal RowIndex As Integer, ByVal pageSize As Integer) As List(Of yourData)
Dim lst = DirectCast(HttpContext.Current.Session("curPage_PLACE"), List(Of Model.PLACE))
Dim pageIndex As Integer = 0 'หาหน้าป้จจุบันโดยทราบตำแหน่งระเบียน(แถวที่)
Dim totalCount As Integer = lst.Count
'*****
'Select * From youTable Where yourCondition Order By yourOrderby
'*****
If RowIndex > 0 Then
pageIndex = CInt(Math.Round(CDbl(RowIndex ) / CDbl(pageSize)))
End If
'อันนี้ใช้ LOCAL LINQ/LAMPDA
Dim r = lst.Skip((pageIndex) * pageSize).Take(pageSize).ToList()
Return r
End Function
Public Shared Function getRows(ByVal pageIndex As Integer, ByVal pageSize As Integer) As List(Of yourData)
Dim lst = DirectCast(HttpContext.Current.Session("curPage_PLACE"), List(Of Model.PLACE))
Dim totalCount As Integer = lst.Count
'*****
'Select * From youTable Where yourCondition Order By yourOrderby
'*****
'อันนี้ใช้ LOCAL LINQ/LAMPDA
Dim r = lst.Skip((pageIndex) * pageSize).Take(pageSize).ToList()
Return r
End Function