Help with dataset and datagrids

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have the following dataset
Loc Qty Amt
OH 5 2
NC 4 1
OH 2 4

I have two datagrids on the same page one for OH and the other for NC. Is it
possible to select only OH rows from one dataset for the first datagrid and
NC rows frm the same dataset for the second datagrid. Instead of executing
two select statements and two

datagrid1.datasource = ds1
datagrid1.databind
datagrid2.datasource.ds2
datagrid2.databind



Thanks
 
Hi Chris,

You can use dataview to perform your task:
Dim dvOH As DataView = ds.Tables(0).DefaultView
dvOH.RowFilter = "Loc='OH'"
datagrid1.datasource = dvOH
datagrid1.databind()

Dim dvNC As DataView = ds.Tables(0).DefaultView
dvNC.RowFilter = "Loc='NC'"
datagrid2.datasource = dvNC
datagrid2.databind()

HTH

Elton Wang
(e-mail address removed)
 
Back
Top