FormView - Paging
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
--
-- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Date:Thu, 09 Aug 2007 17:43:10 +0100
Author:
|