Results 1 to 6 of 6

Thread: [RESOLVED] gridview to dataset

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    India
    Posts
    310

    Resolved [RESOLVED] gridview to dataset

    Hi,

    how to get datatable from gridview???
    somthing like this:
    DataTable dt = gridview1.DataSource as DataTable;
    -------------
    I don't want to save data in session before grid binding.
    -------------
    Sagar
    VB6, VB.net,C#,ASP, ASP.net MSSQL, MYSQL

  2. #2
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: gridview to dataset

    Hello,

    The short answer is that you can't get it back directly, I don't think. You would need to re-generate the DataTable by looping through the rows of the GridView. Something like this:

    Code:
            foreach (GridViewRow row in this.GridView1.Rows)
            {
                DataRow dr = dt.NewRow();
                dr["User Name"] = row.Cells[1].Text;
                dr["User Email"] = row.Cells[2].Text;
                dt.Rows.Add(dr);
            }
    Not pretty.

    If there is another way, I would be interested to know what that is.

    Gary

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    India
    Posts
    310

    Re: gridview to dataset

    I know this.... bt not confirm thats why i post this thread.....
    I am searching for that another way.... i will keep open this thread for 2 or 3 days more if any1 can know much more about this...
    But now I am sure it is not possible.
    If this is thing possible then we can really use disconnected database. I dont want to save dataset in session caz it will create memory issues. Do u agree??
    Sagar
    VB6, VB.net,C#,ASP, ASP.net MSSQL, MYSQL

  4. #4
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: gridview to dataset

    Depending on the size of the DataTable/DataSet that you are using, then yes, it can lead to memory issues. In this type of situation, you need to look at the actual data that you are pulling back to decide whether you actually need all of that data or not.

    What is the actual requirement to retrieve the DataTable again? What information are you trying to get at?

    Gary

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    India
    Posts
    310

    Re: gridview to dataset

    thanks Gary, now I hv thinked lot and I have changed the flow of project n this is quite good and client is very happy for that n concern abt gridview to dataset is not possible or we dnt knw.
    Sagar
    VB6, VB.net,C#,ASP, ASP.net MSSQL, MYSQL

  6. #6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width