Link to home
Start Free TrialLog in
Avatar of scorpion53061
scorpion53061

asked on

Add Column and values in columns in dataset

Only one row of my dataset is being written and it is putting the price with the wrong item. What am I doing wrong?
In thesecond row appears but the price and total column values are not shown
Dim myCol As DataColumn
        Dim myCol1 As DataColumn
        Dim countme As Integer = 0
        cols = dsreport.Tables(0).Columns
        myCol = cols.Add("COST", System.Type.GetType("System.String"))
        myCol1 = cols.Add("TOTAL", System.Type.GetType("System.String"))
        countme = 0
        For countme = 0 To dsreport.Tables(0).Rows.Count '- 1
            dsreport.Tables(0).Rows(countme).Item("TOTAL") = Format(dsreport.Tables(0).Rows(countme).Item("TOTPRICE"), "$##.##0")
            dsreport.Tables(0).Rows(countme).Item("COST") = Format(dsreport.Tables(0).Rows(countme).Item("PRICE"), "$##.##0")
        Next
        dsreport.Tables(0).Columns.Remove("TOTPRICE")
        dsreport.Tables(0).Columns.Remove("PRICE")
Avatar of RonaldBiemans
RonaldBiemans

One question  how is cols defined ?
Avatar of scorpion53061

ASKER

my bad........sorry

Dim cols As DataColumnCollection
Strange, I used your code and I can't find anything wrong with it.
ASKER CERTIFIED SOLUTION
Avatar of RonaldBiemans
RonaldBiemans

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am not doing a datasource for a datagrid. I am writing the dataset data to a document. I need to keep that dataset in tact.