DataView

K

Kiyomi

I have a DataSet defined as follows :



Dim ds As New DataSet

ds.Tables("MyTable").Rows(i)("MyFieldName")



where I can go through from one record to another using 'i'.



Now I created a DataView as follows :



Dim dv As New DataView(ds.Tables("MyTable"))

dv.RowFilter = "MyRowFilter"

dv.Sort = "MySort"



I would like to go through one record to another just as I did for my
DataSet.



How can I do this ?



Thanks,



K
 
R

Rob Meade

...
How can I do this ?

Hi Kiyomi,

Try this:

Dim Iteration As Iteration

For Iteration = 0 To (DataView.Count - 1)

' do something with each item in the data view using;
' variable = DataView.Item(Iteration)("column_name")

Next
 
K

Kiyomi

Thank you, Rob, for your prompt response.

I tried :

dv.Item(0)("MyColumn")

However, Visual Studio 2003 does not like it, telling me that "Expresion is
not a method".

I wonder what's wrong ?

Thanks,
 
R

Rob Meade

...
Thank you, Rob, for your prompt response.

I tried :

dv.Item(0)("MyColumn")

However, Visual Studio 2003 does not like it, telling me that "Expresion
is
not a method".

I wonder what's wrong ?

Ok - a more detailed example :)


' declare variables
Dim EmployeeID As Integer
Dim EmployeeJobTitle As String
Dim EmployeeIteration As Integer

For EmployeeIteration = 0 To (DataView.Count - 1)

' populate variables
EmployeeID = DataView.Item(EmployeeIteration)("UnActionedEmployeeID")
EmployeeJobTitle = DataView.Item(EmployeeIteration)("EmployeeJobTitle")

Next


This was extracted from a page that I use which does work, i think your only
problem was that you weren't putting the value "into" anything...

Regards

Rob
 
R

Rob Meade

...
Can you skip through the different row value's of a DataGrid like that?

Oh I see..

I dont think so, this is from typing "dataview" in Visual Studio and hitting
F1...

"Represents a databindable, customized view of a DataTable for sorting,
filtering, searching, editing, and navigation."

I guess you'd have to create and populate a DataTable with the content you
are putting in your grid, then you could use the DataView. Unless you
really need the grid for something else I guess you could just drop the
grid, use the table/view and then create your own output functions to render
the data to the page (if required).

Hope this helps.

Regards

Rob
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top