First, I should tell you that you're in the wrong newsgroup for this.
I suggest you try one of the ASP.NET newsgroups.
I typically solve the problem by creating a dataset and storing it as a
session variable as in
Dim objDS as New Dataset
objDS = 'Place your code here to create your dataset
'Store the dataset as a session variable
Session("DS") = objDS
From here you could create a DataView to sort the records in the
dataset
Dim objDV As DataView = Session("DS").Tables(0).DefaultView
objDV.Sort = "Column 1 asc"
or you can pick through specific records in your results with a more
precise dataview that includes a criterion
'Filter the records
Dim strValue as String
Dim strID As String = "25"
Dim objDV As DataView = New DataView(Session("DS").Tables(0),
"ContactID=" & strID, "ContactID", DataViewRowState.CurrentRows)
'Find a matching record (in this case only one record)
Dim i As Integer
i = objDV.Find(strID)
If i <> -1 Then
strValue =objDV.Item(i)("Column2")
End If
I can't understand why you're using a Datalist if you want to display
only one record. A datalist is for multiple records and typically
creates an html table. You probably would be better off binding to
individual controls.
Bill Ehrreich
ol**@ylm.se wrote: Hi everyone.
Beging a newbee to asp.net and used to work with traditional asp I
have one problem working with a datalist.
1/ I make a dataset as as session variable like
session("employees")
2/ I want the datalist do display only the first row of the table.
But it always fails.
tried for exemple:
dim nrowpos as ingeger 'shows the current rowposition
dim dv as dataview
dim dt as datatable (connented to the dataset)
dv = dt.Rows(nRowPos).ToString()
datalist1.datalist1.datasource = dv
But everything I tried fails.
Of cource I could instead use av simple web-form without datalist,
but I think that this also must work with a datalist.
I want to do this because I don't want to requery the databas every
time wanted to move to the next record, like you had to to in asp 2.0
Hope someone could help me.