3
Answers

DataTable Show Empty Data

Sudheer Vasam

Sudheer Vasam

8y
347
1

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)