DataView

R

ruca

I'm filtering a DataView. After that I know that filter result only ( and
only) in one row with 4 or 5 columns. Now I want to pic up the value of one
of that columns (that I know only the name, eg. Code).

How can I take this value of that column of my DataView?

I have this:

dv.Table = dt (it's a DataTable variable)
dv.RowFilter = strFilter (that's my filter)
dv.Sort = strSort (that's my sort order)

strCode = .... //here I want to know the value of column named Code.

How can I do this????
 
R

ruca

I already find out.

For anyone want to know, here's the solution:

strCode = CStr(dv(0)(ColumnName).ToString())

I think that this only works for one row result for Filter
 
W

William Ryan eMVP

Hi Ruca:

Listen, if you are looking for the given value of that column at a specific
row, then you can enumerate the DataView like this;

Dim ie As IEnumerator

ie = dv.GetEnumerator

Dim drv As DataRowView

While ie.MoveNext

drv = CType(ie.Current, DataRowView)

MessageBox.Show(drv("ColumnName"))

'or MessageBox.Show(drv(IndexOfColumn))

End While

BTW, I will have part 1 or a 3 part article on advanced usage of dataviews
up tonight around 6:00 at
http://www.knowdotnet.com/articles/dataviews1.html
Where I elaborate on walking through a Dataview in depth (without having to
reference the underlying table).

Cheers,

Bill
 

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