?
Solved

Recreating a dataset based on gridview

Posted on 2007-11-23
2
Medium Priority
?
738 Views
Last Modified: 2013-11-26
Hi guys,

I need to create a dataset that mimicks the data I have in a gridview.  This is part of a custom sorting problem I am having.  

So far i have the code below, but it doesnt return the data that I see on my gridview.  Could someone please let me know how to copy the data??

Thanks in advance.
Phil

Dim dsCurrent As New DataSet
        dsCurrent.Tables.Add()
        For i As Integer = 0 To GridView1.Columns.Count - 1
            dsCurrent.Tables(0).Columns.Add()
        Next
 
        For Each r As UI.WebControls.GridViewRow In GridView1.Rows
            dsCurrent.Tables(0).Rows.Add()
            For i As Integer = 0 To r.Cells.Count - 1
                dsCurrent.Tables(0).Rows(dsCurrent.Tables(0).Rows.Count - 1).Item(i) = r.DataItem(i)
            Next
        Next

Open in new window

0
Comment
Question by:Artform04
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
Munawar Hussain earned 1200 total points
ID: 20340379
if you need to get your datasource back from gridview then you can get it as following
DataTable dt = new DataTable();
dt = (DataTable)GridView1.DataSource;

now dt has all the data which you have bound with gridview.

0
 
LVL 1

Author Comment

by:Artform04
ID: 20345437
Ive ended up just using session vars to store the dataset.  The datasource becomes inaccessible once the page has been bound and Im trying to access it at a later stage. thanks for the help anyway.. have some points
0

Featured Post

Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question