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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top