Click here to Skip to main content
Sign Up to vote bad
good
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:20
Edited 11 Feb '13 - 18:30

Comments
vinodkumarnie - 12 Feb '13 - 1:20
Are you binding gridview using Sqldatasource..?

4 solutions

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  
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 - 14 Feb '13 - 21:39
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
Your Filters
Interested
Ignored
     
0 OriginalGriff 286
1 Mohammed Hameed 268
2 Sergey Alexandrovich Kryukov 218
3 Mayur_Panchal 143
4 Santhosh G_ 108
0 Sergey Alexandrovich Kryukov 8,216
1 OriginalGriff 6,271
2 CPallini 3,528
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid