Dataview Sort

  • Thread starter Charles A. Lackman
  • Start date
C

Charles A. Lackman

Hello I have a DataView using the DataViewManager that was created from a
Dataset with a Relationship.

The Parent View is "Customers"
The Child View is "Contacts"

I am looking for a way to Sort the ContactsView and perform a Find on it.

I.E.

CustomerView.DataViewSettings("Customers.Contacts").Table.DefaultView.Sort =
"ID"

RowPosition =
CustomerView.DataViewSettings("Customers.Contacts").Table.DefaultView.Find("12")


This does not work, any suggestions will be greatly appreciated.

Thanks,

Chuck
 
B

Bart Mermuys

Hi,

Charles A. Lackman said:
Hello I have a DataView using the DataViewManager that was created from a
Dataset with a Relationship.

The Parent View is "Customers"
The Child View is "Contacts"

I am looking for a way to Sort the ContactsView and perform a Find on it.

I.E.

CustomerView.DataViewSettings("Customers.Contacts").Table.DefaultView.Sort
=
"ID"

RowPosition =
CustomerView.DataViewSettings("Customers.Contacts").Table.DefaultView.Find("12")


This does not work, any suggestions will be greatly appreciated.

I'm not entirely sure what you are saying/asking... You are only talking
about DataView's but did you bind in a parent-child way using the
DataViewManager, if you did, can you post some of the binding code or tell
how you setup the binding ?

Are you using NET1.1 or NET2.0 ?

HTH,
Greetings
 
C

Charles A. Lackman

Hello,

I hope this helps.

Customers Table (This works): (CustomerDataset)
ID - Integer
Name - VarChar
Address - VarChar

Contacts Table (This works): (CustomerDataset)
ID - Integer
ContactName- VarChar
ContactPhone- VarChar

The Relationship (This works):
CustomerDataset.Relations.Add("Children",
CustomerDataset.Tables("Customers").Columns("ID"),
CustomerDataset.Tables("Contacts").Columns("ID"), False)

The DataViewManager (This works):
TheCustomerView = New DataViewManager(CustomerDataset)

Find a Row in the Child Table??? (This does NOT work):
Dim RowPosition as Integer
CustomerView.DataViewSettings("Customers.Children").Table.DefaultView.Sort =
"ID"
RowPosition =
CustomerView.DataViewSettings("Customers.Children").Table.DefaultView.Find("12")

Move to the Row (This works):
BindingContext(CustomerView.DataViewSettings("Customers").Table,
"Children").Position = RowPosition


I do a sort on the Customers Table and it returns some rows, in the returned
rows I want to do a search also to display the correct row of data.

Thanks,

Chuck
 
R

RobinS

Are you using .Net 1.1 or .Net 2.0?

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
 
C

Cor Ligthert [MVP]

Charles,

Don't knit while finding a solution.

As far as I can see is the only thing you needs.

TheTable.("Contacts").DefaultView.Sort = "ID"
TheTable.("Contacts").DevaultView.Find("12")

In my idea does your relation not add much in this.

Cor
 
B

Bart Mermuys

Hi,

Charles A. Lackman said:
Hello,

I hope this helps.

Customers Table (This works): (CustomerDataset)
ID - Integer
Name - VarChar
Address - VarChar

Contacts Table (This works): (CustomerDataset)
ID - Integer
ContactName- VarChar
ContactPhone- VarChar

The Relationship (This works):
CustomerDataset.Relations.Add("Children",
CustomerDataset.Tables("Customers").Columns("ID"),
CustomerDataset.Tables("Contacts").Columns("ID"), False)

The DataViewManager (This works):
TheCustomerView = New DataViewManager(CustomerDataset)

Ok so far...
Find a Row in the Child Table??? (This does NOT work):

I guess you mean child view ? Because if you want to find a row inside the
child table, then you could simply use the child table.
Dim RowPosition as Integer
CustomerView.DataViewSettings("Customers.Children").Table.DefaultView.Sort
=
"ID"
RowPosition =
CustomerView.DataViewSettings("Customers.Children").Table.DefaultView.Find("12")
Move to the Row (This works):
BindingContext(CustomerView.DataViewSettings("Customers").Table,
"Children").Position = RowPosition

You're using the Table property, so that's the exact same as:

BindingContext( CustomersDataSet.Tables("Customers"), "Children" ).Position
= RowPosition

Anyways, you still haven't shown how you setup the bindings, so i can only
guess, but it looks like you have bound the child Control(s) to the
Customers table and Childeren relation, you're not even binding to the
DataViewManager and you probely don't need to. Maybe this is what you are
looking for:

Dim childCM As CurrencyManager
Dim childDV As DataView

' when getting the CurrencyManager from the BindingContext, you
' need to use the same DataSource(ref) and DataMember (excluding
' fieldname; can be empty) as you used to setup the DataBinding
childCM = DirectCast( BindingContext(CustomersDataSet.Tables("Customers"),
"Children"), CurrencyManager )
childDV = DirectCast( childCM.List, DataView )

childDV.Sort = "ID"
childCM.Position = childDV.Find("12")

HTH,
Greetings
 
C

Charles A. Lackman

Hello and Thanks for you help.

Everything is working fine now.

Chuck

Hello I have a DataView using the DataViewManager that was created from a
Dataset with a Relationship.

The Parent View is "Customers"
The Child View is "Contacts"

I am looking for a way to Sort the ContactsView and perform a Find on it.

I.E.

CustomerView.DataViewSettings("Customers.Contacts").Table.DefaultView.Sort =
"ID"

RowPosition =
CustomerView.DataViewSettings("Customers.Contacts").Table.DefaultView.Find("12")


This does not work, any suggestions will be greatly appreciated.

Thanks,

Chuck
 

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

Top