D
Doug Bell
Hi,
I have a DataSet with a DataTable that has a number of duplicate rows
(except for one column that has a unique value).
Each row has OrderNo, OrderLineNo, etc and there are multiple rows with
the same OrderNo and OrderLineNo.
I need to display data in a DataGrid but displaying only one record for each
OrderNo OrderLineNo.
I was thinking about constructing a new DataTable holding the Unique
OrderNo-OrderLineNo records, something along the lines of code below but I
need to have the data ordered by 2 columns to do that.
Any ideas or suggestions?
Thanks, Doug
Dim dt as DataTable = New DataTable
dt = dsMyDataSet.Tables("MyDataTable").Clone
Dim dr, drNew as DataRow
Dim drs() as DataRow = dsMyDataSet.Tables("MyDataTable").Select("PickList =
" & PickListNo, "OrderNo ASC") 'How can I sort on 2 Columns OrderNo and
OrderLineNo
Dim iOrd, iOrdLin as Integer
Dim iCol as integer
dim iCols as integer = dt.Columns.Count-1
for each dr in drs
If iOrd <> dr("OrderNo") and iOrdLin <> dr("OrderLineNo") Then
drNew = dt.NewRow
For iCol = 0 to iCols
drNew(iCol) = dr(iCol)
Next iCol
dt.Rows.Add(drNew)
Else
iOrd = dr("OrderNo")
iOrdLin <> dr("OrderLineNo")
End If
next dr
I have a DataSet with a DataTable that has a number of duplicate rows
(except for one column that has a unique value).
Each row has OrderNo, OrderLineNo, etc and there are multiple rows with
the same OrderNo and OrderLineNo.
I need to display data in a DataGrid but displaying only one record for each
OrderNo OrderLineNo.
I was thinking about constructing a new DataTable holding the Unique
OrderNo-OrderLineNo records, something along the lines of code below but I
need to have the data ordered by 2 columns to do that.
Any ideas or suggestions?
Thanks, Doug
Dim dt as DataTable = New DataTable
dt = dsMyDataSet.Tables("MyDataTable").Clone
Dim dr, drNew as DataRow
Dim drs() as DataRow = dsMyDataSet.Tables("MyDataTable").Select("PickList =
" & PickListNo, "OrderNo ASC") 'How can I sort on 2 Columns OrderNo and
OrderLineNo
Dim iOrd, iOrdLin as Integer
Dim iCol as integer
dim iCols as integer = dt.Columns.Count-1
for each dr in drs
If iOrd <> dr("OrderNo") and iOrdLin <> dr("OrderLineNo") Then
drNew = dt.NewRow
For iCol = 0 to iCols
drNew(iCol) = dr(iCol)
Next iCol
dt.Rows.Add(drNew)
Else
iOrd = dr("OrderNo")
iOrdLin <> dr("OrderLineNo")
End If
next dr