Dynamic linksbuttons, VB Class File and custom paging help needed

R

richard

OK, Im finished pulling my hair out and now I need help. I have created
a VB class file for my custom paging, in it I create a table with 2
rows, in the rows I have linkbuttons for first page, previous page,
next page and last page. The buttoms are created like:


CODE
'configure the link buttons
link_1.ID = "f_link"
link_2.ID = "p_link"
link_3.ID = "n_link"
link_4.ID = "l_link"

link_1.Text = "<< First"
link_2.Text = "< Prev"
link_3.Text = "Next >"
link_4.Text = "Last >>"

link_1.CommandArgument = "FirstPage"
link_2.CommandArgument = "PreviousPage"
link_3.CommandArgument = "NextPage"
link_4.CommandArgument = "LastPage"


AddHandler link_1.Command, AddressOf link_click
AddHandler link_2.Command, AddressOf link_click
AddHandler link_3.Command, AddressOf link_click
AddHandler link_4.Command, AddressOf link_click

link_1.CausesValidation = False
link_2.CausesValidation = False
link_3.CausesValidation = False
link_4.CausesValidation = False

in the class file I have serveral properties :

CODE
Public Property DG_Name() As String
Get
Return DGname
End Get
Set(ByVal value As String)
DGname = value
End Set
End Property

Public Property page_num() As Integer
Get
Return my_page
End Get
Set(ByVal value As Integer)
my_page = value
End Set
End Property

Public Property tot_records() As Integer
Get
Return total_records
End Get
Set(ByVal value As Integer)
total_records = value
End Set
End Property

Public Property MyDG() As DataGrid
Get
Return DG
End Get
Set(ByVal value As DataGrid)
DG = value
End Set
End Property

and the variables are declared here:


CODE
Public DG As DataGrid = New DataGrid
Public my_page As Integer
Public total_records As Integer
Public DGname As String

The link_click event is as such:


CODE
Public Sub link_click(ByVal sender As Object, ByVal e As
CommandEventArgs)
Dim lb As LinkButton = CType(sender, LinkButton)

Select Case lb.CommandArgument.ToString.ToLower
Case "firstpage"
DG.CurrentPageIndex = 0
HttpContext.Current.Response.Write("you clicked " &
lb.CommandArgument.ToString)
Case "previouspage"
If DG.CurrentPageIndex = 0 Then
DG.CurrentPageIndex = 0
Else
DG.CurrentPageIndex = page_num - 1
End If
HttpContext.Current.Response.Write("you clicked " &
lb.CommandArgument.ToString)
Case "nextpage"
HttpContext.Current.Response.Write(tot_records & "
:: " & my_page & " :: ")
If (total_records - 1) < page_num Then
DG.CurrentPageIndex = 0
Else
DG.CurrentPageIndex = page_num + 1
End If
HttpContext.Current.Response.Write("you clicked " &
lb.CommandArgument.ToString)

Case "lastpage"
HttpContext.Current.Response.Write("you clicked " &
lb.CommandArgument.ToString)
DG.CurrentPageIndex = CType((DG.PageCount),
Integer)
End Select
End Sub

The response.writes work and tell me what I clicked, in the .aspx.vb
file I set the properties in the class file as such:


CODE
page.my_page = bud_pricing.CurrentPageIndex
name.DG_Name = "bud_pricing"
records.total_records = Rec_Count
DG.DG = bud_pricing

The values set in the aspx.vb file arent getting to the class file so
the paging dont work. The links show up beautifully but they dont page.
Can someone PLEASE help me?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top