magicjoef:Is it possible to navigate programatically to a record in a form view that matches a querystring value, rather than restrict the information I am getting from the database?
you'll have to find the data row, in the source that the formview is bound to, that matches the querystring value and set the PageIndex of the FormView to that row.
'take a page level variable for comparison in the DataBound event:
Dim ID As String = String.Empty
'set it up in the page load event to the querystring value coming in
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not IsPostBack Then
If Request.QueryString("ID") IsNot Nothing Then
ID = Request.QueryString("ID").ToString()
End If
Else
ID = String.Empty
End If
End Sub
'in the DataBound event handler wired up to the FormView:
Private Sub FormView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.DataBound
'this event will fire at all times (paging etc) so..
If Not String.IsNullOrEmpty(ID) Then
Dim fv As FormView = DirectCast(sender, FormView)
If fv IsNot Nothing Then
Dim myDataRowView As DataRowView = TryCast(fv.DataItem, DataRowView)
For iRowIndex As Integer = 0 To myDataRowView.DataView.Count - 1
If myDataRowView.DataView(iRowIndex).Row(0).ToString() = ID Then
'found record
fv.PageIndex = iRowIndex
Exit For
End If
Next
End If
End If
End Sub
* remove any QueryStringParameters you've currently set up on the FormViews' SqlDataSource
you may like to refer this thread: http://forums.asp.net/t/1481943.aspx?PageIndex=2 (does the same with a DetailsView, but I've replaced code for a FormView for you)