Answers for "how to import datagridview to datatable in c#"

C#
0

how to import datagridview to datatable in c#

public DataTable GetDataTable()
{
    DataTable dtLocalC = new DataTable();
    dtLocalC.Columns.Add("splr_Slno");
    dtLocalC.Columns.Add("splr_Cntctnm");
    dtLocalC.Columns.Add("splr_Cntctdesig");
    dtLocalC.Columns.Add("splr_Cntctmoblno");
    dtLocalC.Columns.Add("splr_Cntctemail");

    DataRow drLocal = null;
    foreach (DataGridViewRow dr in dgvSpplrfrm.Rows)
    {
        drLocal = dtLocalC.NewRow();
        drLocal["splr_Slno"] = dr.Cells["splr_Slno"].Value;
        drLocal["splr_Cntctnm"] = dr.Cells["splr_Cntctnm"].Value;
        drLocal["splr_Cntctdesig"] = dr.Cells["splr_Cntctdesig"].Value;
        drLocal["splr_Cntctmoblno"] = dr.Cells["splr_Cntctmoblno"].Value;
        drLocal["splr_Cntctemail"] = dr.Cells["splr_Cntctemail"].Value;
        dtLocalC.Rows.Add(drLocal);
    }

    return dtLocalC;
}
Posted by: Guest on June-17-2020

Code answers related to "how to import datagridview to datatable in c#"

C# Answers by Framework

Browse Popular Code Answers by Language