Creating DataTable for C# Code :
public static DataTable getAllProduct()
{
DataTable table = new DataTable();
DataColumn col1 = new DataColumn("Id");
DataColumn col2 = new DataColumn("Title");
DataColumn col3 = new DataColumn("Entitlement");
DataColumn col4 = new DataColumn("CreatedDate");
DataColumn col5 = new DataColumn("PublishedDate");
DataColumn col6 = new DataColumn("ProductType");
col1.DataType = System.Type.GetType("System.String");
col2.DataType = System.Type.GetType("System.String");
col3.DataType = System.Type.GetType("System.String");
col4.DataType = System.Type.GetType("System.DateTime");
col5.DataType = System.Type.GetType("System.DateTime");
col6.DataType = System.Type.GetType("System.String");
table.Columns.Add(col1);
table.Columns.Add(col2);
table.Columns.Add(col3);
table.Columns.Add(col4);
table.Columns.Add(col5);
table.Columns.Add(col6);
//For Each Subscription Product Purchased
for (int x = 0; x < listOrders.Rows.Count; x++)
{
DataTable gt = getProductsBySubscription(CustomerID);
//For Each Subscription Product
for (int y = 0; y < gt.Rows.Count; y++)
{
DataRow row = table.NewRow();
row[col1] = gt.Rows[y]["Id"].ToString();
row[col2] = gt.Rows[y]["Title"].ToString();
row[col3] = gt.Rows[y]["Entitlement"].ToString();
row[col4] = gt.Rows[y]["CreatedDate"];
row[col5] = gt.Rows[y]["PublishedDate"];
row[col6] = gt.Rows[y]["ProductType"];
table.Rows.Add(row);
}
}
DataTable distinctTable = table.DefaultView.ToTable( /*distinct*/ true);
return distinctTable;
}
Comments
Post a Comment