DataColumn Overloads

Data column Overloads

     DataTable dt = new DataTable("Customers");


       DataColumn dc = new DataColumn {
                    ColumnName = "ID",
                    DataType = typeof(int),
                    AutoIncrement = true,        
                    AutoIncrementSeed = 1,
                    AutoIncrementStep = 1,
                    AllowDBNull = false };
    dt.Columns.Add(dc);


   dt.Columns.Add("ProductName");




   dt.Columns.Add("UnitPrice"typeof(Double));
   dt.Columns.Add("Quantity"typeof(Int16));
   dt.Columns.Add("Total"typeof(Double));

   dt.Columns["Total"].Expression = "UnitPrice*Quantity";
              OR


   dt.Columns.Add("Total"typeof(Double), "UnitPrice*Quantity" );

0 comments

Post a Comment