Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I write a code to add dynamical column and row to a data set but the field is added some where in my data-set so can any one tell how can i resolve this
My code
for (int i = 0; i < Amount.Count; i++)
    {
        DataColumn dc = new DataColumn("Amount");
        local_ds.Tables[0].Columns.Add(dc);
        local_ds.Tables[0].Rows.Add(Amount[i]);
    }


But the field is adding in the next row can any one tell how to achieve this
Posted

1 solution

Try this

DataColumn dc = new DataColumn("Amount");
local_ds.Tables[0].Columns.Add(dc);

for (int i = 0; i < Amount.Count; i++)
{
    local_ds.Tables[0].Rows[i]["Amount"] = Amount[i];
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900