How to Extract data from a SQLDataSource to a datatable

Is it possible to store data that is retrieved by SqlDataSource in a DataTable? I mean, If I dragged and dropped a GridView and an SqlDataSource and then I set up those controls in page designer in Visual Studio, is it possible at some time later to retrieve the data retrieved by the SqlDataSource and then store the data in a DataTable?

Best regards,

  • Result order of a select
  • Get filter the date rand in SQL Server
  • Identify a specific sequence of records in a table
  • xsd schema file must be annotated in SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class?
  • Using SQL Server as a DB queue with multiple clients
  • SqlDependency causes error in other application
  • Yassine Edouiri

  • Formatting XML for Display on an ASP.NET Page
  • How to parameterise table name in ODBC query
  • C# Alter Table and Add a column programmatically ASP.Net & SQL Server
  • Why empty cell throws an error during SQL stored procedure execution
  • SqlDatasource connect to SQL Server 2008 in ASP.NET
  • Table Per Concrete Type (TPC) Inheritance in Entity Framework 6 (EF6)
  • 2 Solutions collect form web for “How to Extract data from a SQLDataSource to a datatable”

    Probably worth having a look at this:
    DataTable out of SQLDataSource

    As far as I can gather, what egoldin is doing is filling the gridview, then using the rowDataBound event, he/she is then taking this data returned and converting it to a table, which can be used at a later stage.

    i got the answer from @Robbie

    Protected Sub DossierGV_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles DossierGV.RowDataBound
        If (e.Row.RowType = DataControlRowType.DataRow) Then
            If Me.firstTime Then
                Dim dv As System.Data.DataView = CType(e.Row.DataItem, System.Data.DataRowView).DataView
                Me.dtDS = dv.ToTable
                Me.firstTime = False
            End If
        End If
    End Sub
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.