Click here to Skip to main content
15,909,437 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to add datagrid record in datattable in window
VB
Dim dt As DataTable = New DataTable
           dt.Load(grdshow)
Posted
Updated 10-Dec-13 23:52pm
v3
Comments
Nelek 11-Dec-13 5:24am    
Step 1) Do a little research. Google is a good start point
Step 2) Start coding
Step 3) Compile and use the debug to solve little issues
Step 4) When you get a problem you don't know how to solve but at least you tried it, then come back and ask for something concrete with a snippet of the code giving problems

Sorry if this is not the answer you were looking for. But this is the "Quick" Answers section. It is better and you get faster help if you make 10 concrete questions about concrete problems, than a big question about a "how-to guide"
manoj s sherje 11-Dec-13 5:51am    
i am using some tech nick but not working
Dim dt As DataTable = New DataTable
dt.Load(grdshow)
another think also use

1 solution

C#
DataTable  table = new DataTable("DGV_SelectedRows");

//1. generating columns to datatable:
foreach(DataGridViewColumn column in dataGridView1.Columns)
     table.Columns.Add(column.Name, typeof(string));

//2. looping through selected rows of dgv, and add them to datatable:
for(int i=0;i<dataGridView1.SelectedRows.Count; i++)
{
    table.Rows.Add();
    for(int j=0;j<dataGridView1.Columns.Count; j++)
    {
         table.Rows[i][j] = dataGridView1[j,i].Value;
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900