Forcing DataView to sort/filter without calling Control.DataBind?

E

ejstembler

I've noticed that applying a Sort and/or RowFilter property to a
DataView does not take effect until you bind the DataView to a control
and call the control's DataBind method. I'm sure DataBind does some
"magic" internally to apply the sort and filter (perhaps even
generating a new DataView).

Does anyone know how to force the DataView to sort/filter with calling
a control's DataBind? Or even this there is some little-know method
for re-generating the view?

TIA
 
E

ejstembler

Nevermind. Shortly after posting this I found what I was doing wrong:

I was (incorrectly) doing this:

foreach (DataRow row in dataView.Table.Rows)

instead of (correctly) doing this:

foreach (DataRowView row in dataView)
 
C

Cor Ligthert [MVP]

Ejstembler,

Thanks for replying your question did look so crazy for me.

To explain what you do with this one.
DataView.Table gives back the original datatable.

Cor
 

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