Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
How to store Gridview data into Datatable
 
my code is:
DataTable dtt=new DataTable();
dtt.Merge(gridview2.DataSource);
Posted 11-Feb-13 18:20pm
Edited 11-Feb-13 18:30pm
v2
Comments
vinodkumarnie at 12-Feb-13 1:20am
   
Are you binding gridview using Sqldatasource..?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Data Source type of GridView and DataTable is different. You need to convert it like this.
 
BindingSource source = (BindingSource)gridView1.DataSource;
DataTable dt = (DataTable)source.DataSource;
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

its very simple i will show u a sample method u just tweak it according to your needs
 
string str = "select pcode,fyyear,date,salary,ta,contigency,nrc,institcharges,others from monthly";
        SqlDataAdapter adp = new SqlDataAdapter(str, con);
        DataTable dt = new DataTable();
        adp.Fill(dt);
        GridView1.DataSource = dt;
        GridView1.DataBind();
  Permalink  
Comments
Sheikh Muhammad Haris at 14-Feb-13 21:39pm
   
He didn't want to bind GridView data. He asks for getting gridview data in a data table

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

  Print Answers RSS
0 OriginalGriff 298
1 Sergey Alexandrovich Kryukov 181
2 Yogesh Kumar Tyagi 165
3 ChauhanAjay 156
4 Richard Deeming 150
0 Sergey Alexandrovich Kryukov 6,218
1 OriginalGriff 5,413
2 CPallini 2,473
3 Richard MacCutchan 1,627
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100