defaultview is empty, although no filter is set

I

Isa

Hi Newsgroup,

I have a problem with the RowFilter.
When I check my datatable in the debugger, I get the following result:

table1.Rows.Count 3
table1.DefaultView.RowFilter ""
table1.DefaultView.RowStateFilter Unchanged | Added | ModifiedCurrent
table1.DefaultView.Count 0
table1.Rows[0].RowState Unchanged
table1.Rows[1].RowState Unchanged
table1.Rows[2].RowState Unchanged

The table has 3 rows, no filters are set for the defaultview, but the
defaultview has 0 rows.
This occurs after the table was filled by several merge operations.
Does anybody know, how I can refresh the defaultview?

Thank you for your help.

Best regards
Isa
 
C

Cor Ligthert [MVP]

Isa,

You never can refresh a DataView, because it holds no data. It only shows
data from a datatable accooriding the setting of the properties from the
DataView.

Therefore you probably has set something wrong related to your merge
operations, but how can we see that. In your case I would just break it down
until you I see the rows.

Cor
 
R

RobinS

According to MSDN, "DefaultView is a property that returns
a DataView you can use to sort, filter, and search a DataTable."

Maybe you have to apply something to it to get a count.
I don't use the DefaultView; if I want a view of the data in a
DataTable, I create a new DataView object and go to town.

What exactly are you trying to accomplish?

Robin S.
 
I

Isa

thank you for your responses.
We a using a third party datagrid that uses the defaultview, if you use
a datatable as the grid's datasource. I could also use own dataviews
instead of datatables, but we would need to change this in many parts
of our application.
I tried to refresh the defaultview by setting the Rowfilter to "1=1",
afterwards the defaultview was o.k. and filtered all 3 rows. But this
works only one time after the next resetting and filling the datatable,
I would need to change the rowfilter e.g. to "2=2" ("1=1" don't work
the second time, I think the defaultview needs any changes in its
rowfilter to be refreshed (I know it's only a view, but it seems, that
it needs something that triggers the execution of the view)).
Before I fill the tables, I execute a table1.reset(), not only a clear,
because the datatable has columns, which were added dynamically and
must be resetted. Perhaps this cause the problem, but I don't know how
to "repair" the defaultview afterwards.

Best regards
Isa
 
R

RobinS

RESET returns the table to its original, uninitialized state.
Hopefully, that's your intent. I don't know how that would
cause a problem with the DefaultView; one would think it would
also reset the view. Sorry I can't help you more.

Robin S.
----------------------------
 
C

Cor Ligthert [MVP]

Robin,

Why not the defaultview, it is the most near the original table.

Cor

RobinS said:
According to MSDN, "DefaultView is a property that returns
a DataView you can use to sort, filter, and search a DataTable."

Maybe you have to apply something to it to get a count.
I don't use the DefaultView; if I want a view of the data in a
DataTable, I create a new DataView object and go to town.

What exactly are you trying to accomplish?

Robin S.
------------------------------------------

Isa said:
Hi Newsgroup,

I have a problem with the RowFilter.
When I check my datatable in the debugger, I get the following result:

table1.Rows.Count 3
table1.DefaultView.RowFilter ""
table1.DefaultView.RowStateFilter Unchanged | Added | ModifiedCurrent
table1.DefaultView.Count 0
table1.Rows[0].RowState Unchanged
table1.Rows[1].RowState Unchanged
table1.Rows[2].RowState Unchanged

The table has 3 rows, no filters are set for the defaultview, but the
defaultview has 0 rows.
This occurs after the table was filled by several merge operations.
Does anybody know, how I can refresh the defaultview?

Thank you for your help.

Best regards
Isa
 
C

Cor Ligthert [MVP]

Isa,

A filter is a column and a variable.

Do I have to assume that you have named your columns 1, 2 and 3.

A little bit confusing don't you think so?

Cor
 
I

Isa

I think the problem is caused by the reset function. All other
defaultviews are not affected.
I have changed the code, so that I don't need the reset function;
instead of this I create a new instance of the datatable.

Thanks to all for your help!
Isa

Cor:
A little bit confusing don't you think so?
yes I think so :) Why do you think I have named my columns 1,2,3 ?
 
B

Bart Mermuys

Hi,

Isa said:
I think the problem is caused by the reset function. All other
defaultviews are not affected.
I have changed the code, so that I don't need the reset function;
instead of this I create a new instance of the datatable.

I haven't had a chance to look into the problem, but i remembered there was
a similar question and answer on csharp not lang ago,
http://groups.google.be/group/micro...atatable++reset&rnum=4&hl=nl#c51d720ed7bf0937

Maybe this can help you ...

Greetings
 
R

RobinS

The ADO book I read didn't really talk about the DefaultView.
When it talked about DataViews, the examples always displayed
creating your own, so that's what I do. I guess you do what
you know.

Robin S.
----------------------
Cor Ligthert said:
Robin,

Why not the defaultview, it is the most near the original table.

Cor

RobinS said:
According to MSDN, "DefaultView is a property that returns
a DataView you can use to sort, filter, and search a DataTable."

Maybe you have to apply something to it to get a count.
I don't use the DefaultView; if I want a view of the data in a
DataTable, I create a new DataView object and go to town.

What exactly are you trying to accomplish?

Robin S.
------------------------------------------

Isa said:
Hi Newsgroup,

I have a problem with the RowFilter.
When I check my datatable in the debugger, I get the following
result:

table1.Rows.Count 3
table1.DefaultView.RowFilter ""
table1.DefaultView.RowStateFilter Unchanged | Added |
ModifiedCurrent
table1.DefaultView.Count 0
table1.Rows[0].RowState Unchanged
table1.Rows[1].RowState Unchanged
table1.Rows[2].RowState Unchanged

The table has 3 rows, no filters are set for the defaultview, but
the
defaultview has 0 rows.
This occurs after the table was filled by several merge operations.
Does anybody know, how I can refresh the defaultview?

Thank you for your help.

Best regards
Isa
 

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