I created columns in the grid, manually added lines to the same.

dataGridView1.Rows.Add(...) 

Now I want to bind the data from the datagridview to datatable , but the datagridview.datasource shows null .. Although there is data in the grid.

    1 answer 1

    Do you want to "merge data" from a GridView into a table or what? Null in the datasource , because nothing was originally specified as the source. By clicking the button in the handler:

    1. Create a DataTable and form a structure as in a grid.
    2. Run through all the columns in the GridView and write the column data to the newly formed DataTable .
    3. Save DataTable .
    4. Attached GridView.DataSource = DataTable; GridView.Bind ();

    Although it seems like everyone else is doing the opposite :)