FormView - Paging

D

DesCF

I have programatically created a DataSet (mdsShippers) that consists of a
single DataTable - the Shippers table from Northwind. I have then added a
FormView control to my WebForm and then two text-boxes in the ItemTemplate
(txShipperID and txtCompanyName). In order to get the FormView to display
and page through the records properly I have written the sode shown
below. However, I have arrived at it through experimentation without
really knowing what I am doing. My question is, am I doing what I am
doing right ?


Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

If Not Page.IsPostBack Then
bdl_LoadShips() ' Creates DataSet and populates DataTable
Else
Me.mdsShippers = Session("Shippers")
End If

With Me.fvShippers
.DataSource = Me.mdsShippers.Tables("dtShippersLIST")
.DataBind()
End With

End Sub

Protected Sub fvShippers_PageIndexChanging(ByVal sender As Object, ByVal
e As System.Web.UI.WebControls.FormViewPageEventArgs) Handles
fvShippers.PageIndexChanging

Me.fvShippers.PageIndex = e.NewPageIndex
Me.fvShippers.DataBind()

End Sub

Protected Sub Page_Unload(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Unload

Session("Shippers") = Me.mdsShippers

End Sub


--
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top