Sudheer Vasam

Sudheer Vasam

  • NA
  • 58
  • 4.8k

DataTable Show Empty Data

Jul 15 2016 2:35 AM

0down votefavorite

if(session["cart"]!=null) {

DataTable da = new DataTable(); 
DataTable dtb = (DataTable)Session["cart"];            
da = dtb.Clone(); 
DataRow dr = da.NewRow();             
dr["ProductName"] = ds.Tables[0].Rows[0]["ProductName"];            
dr["ProductImages"] = ds.Tables[0].Rows[0]["ProductImage"];            
dr["Price"] = ds.Tables[0].Rows[0]["Price"];            
da.Rows.Add(dr); 
foreach(DataRow row in da.Rows ) 
{                  
   dt.ImportRow(row); 
}

return dt;

}

Here dt comes with an Emptydata..............

Structure of datatable dt is .......

dt.Columns.Add("ProductImages", typeof(string));
dt.Columns.Add("ProductName", typeof(string));
dt.Columns.Add("Price", typeof(double));
c#-4.0

Answers (3)