Click here to Skip to main content
12,761,826 members (42,656 online)
Rate this:
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();
Posted 11-Feb-13 19:20pm
Updated 11-Feb-13 19:30pm
vinodkumarnie 12-Feb-13 1:20am
Are you binding gridview using Sqldatasource..?
Rate this: bad
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;
Rate this: bad
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();
        GridView1.DataSource = dt;
Sheikh Muhammad Haris 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2017
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