Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: index of item in list C# 
Csharp :: array to list c 
Csharp :: callback function on animation end unity 
Csharp :: How to take input on float in c# 
Csharp :: difference between alpha and beta testing 
Csharp :: Configure Automapper 
Csharp :: increment operator c# 
Csharp :: csharp datagridview filter column 
Csharp :: shorthand if c# 
Csharp :: c# get all enum values 
Csharp :: dotnet call webapi 
Csharp :: weapon switching unity 
Csharp :: calculate distance using latitude and longitude c# 
Csharp :: check if file exist c# 
Csharp :: null coalescing operator c# 
Csharp :: c# see if list contains any duplicates 
Csharp :: basic auth swagger .net core 5 
Csharp :: C# loop through array of objet 
Csharp :: c# settings file 
Csharp :: vector3 unity 
Csharp :: C# using variables inside strings 
Csharp :: how to get keyboard input in unity 
Csharp :: how to get previous page url aspnet core 
Csharp :: C# async to sync 
Csharp :: limiting the amount of decimal places c# 
Csharp :: verify if number c# 
Csharp :: Read a Word Document Using C# 
Csharp :: stringbuilder to string c# 
Csharp :: And this is how can you deserialize your XML file in your C# code: 
Csharp :: unity add button 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =