Home All Groups Group Topic Archive Search About

DataView on two DataTables

Author
10 Feb 2007 5:00 PM
Garik
Hi,

Please, help. Can I create a DataView on top of more than one DataTable.
If not, how can I implement this for sorting, filtering?????

--
Regards,
Garik Melkonyan
MCP, MCAD, MCSD .NET

Author
11 Feb 2007 10:18 AM
Frans Bouma [C# MVP]
Garik wrote:

> Hi,
>
> Please, help. Can I create a DataView on top of more than one
> DataTable.  If not, how can I implement this for sorting,
> filtering?????

    A dataview is a view on a single table. It contains the rows from the
underlying datatable matching the filter you set sorted using the
sorter you set.

        FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Author
11 Feb 2007 2:02 PM
Cor Ligthert [MVP]
> If not, how can I implement this for sorting, filtering?????
>
That is completely dependend from what you want, however as Frans said, a
dataview is only doing one table, therefore tell what you want, and what is
the data in your rows (and what are the relations)

Cor
Author
11 Feb 2007 3:26 PM
Garik
For example I have two tables: Order Header and Customer, and a relation
OrderHeader.CustKey = Customer.CustKey.

So, I want to show Orders in the DataGridView, and Filter or Sort that grid
by 'Customer.CustomerName, Order.OrderDate DESC'.

Thanks.

Show quote
"Cor Ligthert [MVP]" wrote:

>
> > If not, how can I implement this for sorting, filtering?????
> >
> That is completely dependend from what you want, however as Frans said, a
> dataview is only doing one table, therefore tell what you want, and what is
> the data in your rows (and what are the relations)
>
> Cor
>
>
>
Author
11 Feb 2007 11:53 PM
Cor Ligthert [MVP]
Garik,

Not giving the fish I would say, that in your case I would probably do
something as filtering either using the Select or the DataView the Parent
table on the CustKeys I want and than use that to get the children. (That is
an existing method from datarow). Then you have the collection of datarows
that you want to show.

Cor

Show quote
"Garik" <garik_ma@do not spam.yahoo.com> schreef in bericht
news:4F794C82-B126-49C2-98EC-D07E64F9F742@microsoft.com...
> For example I have two tables: Order Header and Customer, and a relation
> OrderHeader.CustKey = Customer.CustKey.
>
> So, I want to show Orders in the DataGridView, and Filter or Sort that
> grid
> by 'Customer.CustomerName, Order.OrderDate DESC'.
>
> Thanks.
>
> "Cor Ligthert [MVP]" wrote:
>
>>
>> > If not, how can I implement this for sorting, filtering?????
>> >
>> That is completely dependend from what you want, however as Frans said, a
>> dataview is only doing one table, therefore tell what you want, and what
>> is
>> the data in your rows (and what are the relations)
>>
>> Cor
>>
>>
>>
Author
12 Feb 2007 10:19 AM
Garik
Thank you Core,

But this will not resolve my problem, because I must bind the joined data to
the DataGrid. But in your supposed case I must programatically fill the grid.

I want users would see the joined grid, and sort or filter the data (as they
do in SQL Server (e.g. Enterprise Manager).

Garik

Show quote
"Cor Ligthert [MVP]" wrote:

> Garik,
>
> Not giving the fish I would say, that in your case I would probably do
> something as filtering either using the Select or the DataView the Parent
> table on the CustKeys I want and than use that to get the children. (That is
> an existing method from datarow). Then you have the collection of datarows
> that you want to show.
>
> Cor
>
Author
12 Feb 2007 12:12 PM
Bart Mermuys
Hi,

"Garik" <garik_ma@do not spam.yahoo.com> wrote in message
news:4F794C82-B126-49C2-98EC-D07E64F9F742@microsoft.com...
> For example I have two tables: Order Header and Customer, and a relation
> OrderHeader.CustKey = Customer.CustKey.

Suppose you want to show OrderHeader fields but also
OrderHeader.Customer.Name, then you could "import" the Customer.Name into
the OrderHeader table (if you have the right relation), eg.:

OrderHeader table:
- Add column:
    - Name : "CustomerName"
    - Expression : "parent(fk_customer_orderheader).Name"

Once you have that, you should be able to filter and sort using the
BindingSource.

HTH,
Greetings

Show quote
>
> So, I want to show Orders in the DataGridView, and Filter or Sort that
> grid
> by 'Customer.CustomerName, Order.OrderDate DESC'.
>
> Thanks.
>
> "Cor Ligthert [MVP]" wrote:
>
>>
>> > If not, how can I implement this for sorting, filtering?????
>> >
>> That is completely dependend from what you want, however as Frans said, a
>> dataview is only doing one table, therefore tell what you want, and what
>> is
>> the data in your rows (and what are the relations)
>>
>> Cor
>>
>>
>>
Author
12 Feb 2007 5:55 PM
Garik
Thank you Bart Mermuys,

It is the exact solution I was looking for.

I tried using Expression Columns, but I don't realize when the expression is
evaluated? Is the value in the column will be changed, if I modify the row in
the Parent (Customer) table? Is the value in the column will be changed, if I
modify Foreign Key column in the Child table (OrderHeader)?

If expression is evaluated every time when I query the value in the column,
the performance will be very slow in my view.

--
Regards,
Garik Melkonyan
MCP, MCAD, MCSD .NET


Show quote
"Bart Mermuys" wrote:

> Hi,
>
> "Garik" <garik_ma@do not spam.yahoo.com> wrote in message
> news:4F794C82-B126-49C2-98EC-D07E64F9F742@microsoft.com...
> > For example I have two tables: Order Header and Customer, and a relation
> > OrderHeader.CustKey = Customer.CustKey.
>
> Suppose you want to show OrderHeader fields but also
> OrderHeader.Customer.Name, then you could "import" the Customer.Name into
> the OrderHeader table (if you have the right relation), eg.:
>
> OrderHeader table:
>  - Add column:
>     - Name : "CustomerName"
>     - Expression : "parent(fk_customer_orderheader).Name"
>
> Once you have that, you should be able to filter and sort using the
> BindingSource.
>
> HTH,
> Greetings
>
> >
> > So, I want to show Orders in the DataGridView, and Filter or Sort that
> > grid
> > by 'Customer.CustomerName, Order.OrderDate DESC'.
> >
> > Thanks.
> >
> > "Cor Ligthert [MVP]" wrote:
> >
> >>
> >> > If not, how can I implement this for sorting, filtering?????
> >> >
> >> That is completely dependend from what you want, however as Frans said, a
> >> dataview is only doing one table, therefore tell what you want, and what
> >> is
> >> the data in your rows (and what are the relations)
> >>
> >> Cor
> >>
> >>
> >>
>
>
>
Author
12 Feb 2007 7:42 PM
Bart Mermuys
Hi,

Show quote
"Garik" <garik_ma@do not spam.yahoo.com> wrote in message
news:B23EFE4A-CED8-4753-90EF-5DF6D7299761@microsoft.com...
> Thank you Bart Mermuys,
>
> It is the exact solution I was looking for.
>
> I tried using Expression Columns, but I don't realize when the expression
> is
> evaluated?

> Is the value in the column will be changed, if I modify the row in
> the Parent (Customer) table? Is the value in the column will be changed,
> if I
> modify Foreign Key column in the Child table (OrderHeader)?

It looks like the expression is evaluated when either of the two changes you
mention happen.

>
> If expression is evaluated every time when I query the value in the
> column,
> the performance will be very slow in my view.

I believe the expression is _not_ evaluated each time you access the value,
if that's what you mean.

HTH,
Greetings

Show quote
>
> --
> Regards,
> Garik Melkonyan
> MCP, MCAD, MCSD .NET
>
>
> "Bart Mermuys" wrote:
>
>> Hi,
>>
>> "Garik" <garik_ma@do not spam.yahoo.com> wrote in message
>> news:4F794C82-B126-49C2-98EC-D07E64F9F742@microsoft.com...
>> > For example I have two tables: Order Header and Customer, and a
>> > relation
>> > OrderHeader.CustKey = Customer.CustKey.
>>
>> Suppose you want to show OrderHeader fields but also
>> OrderHeader.Customer.Name, then you could "import" the Customer.Name into
>> the OrderHeader table (if you have the right relation), eg.:
>>
>> OrderHeader table:
>>  - Add column:
>>     - Name : "CustomerName"
>>     - Expression : "parent(fk_customer_orderheader).Name"
>>
>> Once you have that, you should be able to filter and sort using the
>> BindingSource.
>>
>> HTH,
>> Greetings
>>
>> >
>> > So, I want to show Orders in the DataGridView, and Filter or Sort that
>> > grid
>> > by 'Customer.CustomerName, Order.OrderDate DESC'.
>> >
>> > Thanks.
>> >
>> > "Cor Ligthert [MVP]" wrote:
>> >
>> >>
>> >> > If not, how can I implement this for sorting, filtering?????
>> >> >
>> >> That is completely dependend from what you want, however as Frans
>> >> said, a
>> >> dataview is only doing one table, therefore tell what you want, and
>> >> what
>> >> is
>> >> the data in your rows (and what are the relations)
>> >>
>> >> Cor
>> >>
>> >>
>> >>
>>
>>
>>
Author
11 Feb 2007 3:24 PM
Miha Markic [MVP C#]
Why don't you join, filter and sort within sql statement?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Show quote
"Garik" <garik_ma@do not spam.yahoo.com> wrote in message
news:DF904E82-9842-4089-89C8-F6C893D40F34@microsoft.com...
> Hi,
>
> Please, help. Can I create a DataView on top of more than one DataTable.
> If not, how can I implement this for sorting, filtering?????
>
> --
> Regards,
> Garik Melkonyan
> MCP, MCAD, MCSD .NET
Author
11 Feb 2007 3:33 PM
Garik
I'm not working with sql database:((


Show quote
"Miha Markic [MVP C#]" wrote:

> Why don't you join, filter and sort within sql statement?
>
>

AddThis Social Bookmark Button