hello,

so the DataView object is confusing me. i have a dataset of a bunch of
rows, some of white my page needs to filter out before binding. no
problem, i make a new dataview, set a filter and then bind the dv to my
page. ala:

DataView myDV = New DataView(myDS.Tables[0], "Show=1", "ID DESC",
DataViewRowState.CurrentRows);
myRepeater.DataSource = myDV;

...this is cool and it only shows what its supposed to.

however, what confuses me is... when i try to get the first row of my
filtered view, i do this:

someLabel.Text = myDV.Table.Rows[0][0];

...i am getting a row that was filtered out! (the first row happens to
be one i dont want to show). i had thought the DataView was a new
collection of criteria-matching rows. whaaa? guess not.

so i have two questions:

1) how does a DataList/Grid/whatever know to exclude binding filtered
out items
2) how can i call up a single item from *only* the list of
criteria-matching rows?


thanks!
matt

RE: DataView rows - filtered by SaravananKV

SaravananKV
Fri Mar 11 01:37:10 CST 2005

Hi,

First of all DataView is not a view of the whole underlying DataSet. But, it
is a view of any single table contained in a DataSet.

If you write some code like this,

someLabel.Text = myDV.Table.Rows[0][0];

this actually fetches data from the underlying DataTable of the dataview.
Hence, you get the unfiltered data.

For getting the filtered data, you can try:

someLabel.Text = myDV[0][0];

The dataview is like a DataTable or an array of rows.

Saravanan K V

"matt@mailinator.com" wrote:

> hello,
>
> so the DataView object is confusing me. i have a dataset of a bunch of
> rows, some of white my page needs to filter out before binding. no
> problem, i make a new dataview, set a filter and then bind the dv to my
> page. ala:
>
> DataView myDV = New DataView(myDS.Tables[0], "Show=1", "ID DESC",
> DataViewRowState.CurrentRows);
> myRepeater.DataSource = myDV;
>
> ....this is cool and it only shows what its supposed to.
>
> however, what confuses me is... when i try to get the first row of my
> filtered view, i do this:
>
> someLabel.Text = myDV.Table.Rows[0][0];
>
> ....i am getting a row that was filtered out! (the first row happens to
> be one i dont want to show). i had thought the DataView was a new
> collection of criteria-matching rows. whaaa? guess not.
>
> so i have two questions:
>
> 1) how does a DataList/Grid/whatever know to exclude binding filtered
> out items
> 2) how can i call up a single item from *only* the list of
> criteria-matching rows?
>
>
> thanks!
> matt
>
>

Re: DataView rows - filtered by Miha

Miha
Fri Mar 11 01:41:39 CST 2005


<matt@mailinator.com> wrote in message
news:1110521953.083036.167360@o13g2000cwo.googlegroups.com...
> hello,
>
> so the DataView object is confusing me. i have a dataset of a bunch of
> rows, some of white my page needs to filter out before binding. no
> problem, i make a new dataview, set a filter and then bind the dv to my
> page. ala:
>
> DataView myDV = New DataView(myDS.Tables[0], "Show=1", "ID DESC",
> DataViewRowState.CurrentRows);
> myRepeater.DataSource = myDV;
>
> ...this is cool and it only shows what its supposed to.
>
> however, what confuses me is... when i try to get the first row of my
> filtered view, i do this:
>
> someLabel.Text = myDV.Table.Rows[0][0];

In this way you are accessing DataTable directly.
Instead, you should do something like:
someLabel.Text = myDV[0].Row[0];
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
SLODUG - Slovene Developer Users Group www.codezone-si.info



Re: DataView rows - filtered by Matthew

Matthew
Fri Mar 11 12:41:03 CST 2005

sweet, thanks people.