Home All Groups Group Topic Archive Search About

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

Author
22 Feb 2006 9:58 PM
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

Author
22 Feb 2006 10:25 PM
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)
Author
23 Feb 2006 8:18 AM
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

AddThis Social Bookmark Button