try
{
DataTable dtdcnomissing = new DataTable();
dtdcnomissing.Clear();
dtdcnomissing = objRetailBAL.DCNOMissing(objRetailPL);
DataTable dtimport = new DataTable();
DataTable dtmissingreport = new DataTable();
for (int i = 0; i <= dtdcnomissing.Rows.Count - 1; i++)
{
dtmissingreport.Clear();
objRetailPL.dcnoint = Convert.ToInt32(dtdcnomissing.Rows[i]["id"].ToString());
dtmissingreport = objRetailBAL.DCNOMissingReport(objRetailPL);
dtimport = dtmissingreport.Clone();
foreach (DataRow dr in dtmissingreport.Rows)
{
dtimport.ImportRow(dr);
}
}
GVDCNoMissingReport.DataSource = dtimport;
GVDCNoMissingReport.DataBind();
}
我想将dtmissingreport数据表值存储到dtimport datatable中...但是我没有得到正确的结果......我怎样才能存储它..
答案 0 :(得分:1)
尝试复制()而不是克隆()
DataTable dtNew=yourOldDL.Copy();//it will copy data and structure
DataTable dtNew=yourOldDL.Clone();//it will copy structure only
答案 1 :(得分:1)
Try this below code..
try
{
DataTable dtdcnomissing = new DataTable();
dtdcnomissing.Clear();
dtdcnomissing = objRetailBAL.DCNOMissing(objRetailPL);
DataTable dtimport = new DataTable();
DataTable dtmissingreport = new DataTable();
for (int i = 0; i <= dtdcnomissing.Rows.Count - 1; i++)
{
dtmissingreport.Clear();
objRetailPL.dcnoint = Convert.ToInt32(dtdcnomissing.Rows[i]["id"].ToString());
dtmissingreport = objRetailBAL.DCNOMissingReport(objRetailPL);
if (dtimport.Rows.Count == 0)
dtimport = dtmissingreport.Clone();
foreach (DataRow dr in dtmissingreport.Rows)
{
dtimport.ImportRow(dr);
}
}
GVDCNoMissingReport.DataSource = dtimport;
GVDCNoMissingReport.DataBind();
}