Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setting a Formview record
Message
From
17/06/2008 12:25:54
 
General information
Forum:
ASP.NET
Category:
Web forms
Miscellaneous
Thread ID:
01323266
Message ID:
01324802
Views:
17
As far as I have been able to determine there are 2 ways to get at a specific record, both of which are unacceptable.

1. We can control the SELECT associated with the datasource as you suggest. The downside of this is that there is only the one record available to the formview and the ability to page through additional records is eliminated.
2. We can loop through all the records until we find the one we want. The downside of this is that it only works in the formview_prerender and takes forever if the page is the least bit complex. Presumably the page is actually rendered (not visible) with each loop.

So . . I'm still looking for a better way.

>Why you can not properly set the Select parameter?
>
>>Thanks for the idea. It tells me the Datakey is readonly.
>>
>>>I don't know, but would something like setting DataKey work?
>>>
>>>>Does anyone here know how to position a formview to a specific record? I have the following code:
>>>>
>>>>    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
>>>>        Dim i As Int32
>>>>        Dim CurrentRecord As Integer = Session("CurrentPerson")
>>>>
>>>>        If Not IsPostBack() And CurrentRecord > 0 Then
>>>>            FormView1.DataBind()
>>>>
>>>>            ' Go to the record we want
>>>>            For i = 0 To FormView1.DataItemCount - 1
>>>>                FormView1.PageIndex = i
>>>>
>>>>                If FormView1.DataItem("personID") = CurrentRecord Then
>>>>                    Exit For
>>>>                End If
>>>>            Next
>>>>        End If
>>>>           End Sub
>>>>
>>>>which works when placed in the Formview prerender (but it takes forever) and does not work in the PageLoad. This seems like it should be a trivial task but I just can't seem to get it. Any help appreciated.
Previous
Reply
Map
View

Click here to load this message in the networking platform