Click here to Skip to main content
14,695,085 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sample data ............

Data_Table
[
Col1
Col2
Col3
]
_objSumList
[
 100		    
 1.78189086914		
 2.07949829101599
]

Data Displaying like this

Col1                   Col2              Col3

 100		    
 1.78189086914		
 2.07949829101599


But i need data below format

Col1                   Col2              Col3

 100		    1.78189086914       2.07949829101599


Please Suggest me,

Thank you.

What I have tried:

By using

for (int k = 0; k < _objSumList.Count; k++)
{
 Data_Table.Rows.Add(_objSumList[k].ToString());
}
Posted
Updated 5-Feb-18 3:52am
v3

1 solution

try this :

namespace ConsoleApplication2
{
    public class DT
    {
        public double Col1;
        public double Col2;
        public double Col3;
    }
    class Program
    {
        static void Main(string[] args)
        {

            DT dt = new DT();
            DataTable dtb = new DataTable();

            dtb.Columns.Add("col1");
            dtb.Columns.Add("col2");
            dtb.Columns.Add("col3");

            DataRow dr1 = dtb.NewRow();

            dr1["col1"] = 100;
            dr1["col2"] = 1.78189086914;
            dr1["col3"] = 2.07949829101599;
            dtb.Rows.Add(dr1);
            foreach (DataRow dr in dtb.Rows)
            {
                dt.Col1 = Convert.ToDouble(dr["col1"]);
                dt.Col2 = Convert.ToDouble(dr["col2"]);
                dt.Col3 = Convert.ToDouble(dr["col3"]);
            }
		}
	}
}
   

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