Answers for "c# datagridview Load data from DataTable"

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
0

c# datagridview Load data from DataTable

DataTable table;
 
private void Form1_Load(object sender, EventArgs e)
        {
            table = new DataTable();
 
            table.Columns.Add("Id", typeof(int));
            table.Columns.Add("FirstName", typeof(string));
            table.Columns.Add("LastName", typeof(string));
            table.Columns.Add("City", typeof(string));
 
            table.Rows.Add(1, "Leon", "Ardon", "Paris");
            table.Rows.Add(2, "Ben", "Jamir", "London");
            table.Rows.Add(3, "Samuel", "Toe", "Berlin");
            table.Rows.Add(4, "Lila", "Foe", "Madrid");
 
            dataGridView1.DataSource = table;
        }
Posted by: Guest on September-23-2021

Code answers related to "c# datagridview Load data from DataTable"

C# Answers by Framework

Browse Popular Code Answers by Language