[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Recreating a dataset based on gridview

Posted on 2007-11-23
2
Medium Priority
?
739 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
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 …

650 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