Results 1 to 3 of 3

Thread: Getting DataTable, the data source, back from a datagrid?

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Getting DataTable, the data source, back from a datagrid?

    How can I do this:
    The code I am playing with is pretty simple.
    I have displayed a datatable in my datagrid.
    I can see the data perfectly.

    I just want to know if I can do something like:
    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim dt As DataTable = CType(MyDataGrid.DataSource, DataTable)
        Response.Write(dt.Rows.Count.ToString)
    End Sub
    Or would I have to store the datatable in the viewstate of the page manually?

    Woka

  2. #2
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    Re: Getting DataTable, the data source, back from a datagrid?

    not sure about your question, havent tried it.

    maybe a session variable or a temp xml file?

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Getting DataTable, the data source, back from a datagrid?

    Quote Originally Posted by Wokawidget
    How can I do this:
    The code I am playing with is pretty simple.
    I have displayed a datatable in my datagrid.
    I can see the data perfectly.

    I just want to know if I can do something like:
    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim dt As DataTable = CType(MyDataGrid.DataSource, DataTable)
        Response.Write(dt.Rows.Count.ToString)
    End Sub
    Or would I have to store the datatable in the viewstate of the page manually?

    Woka
    You'd have to use a viewstate. If you're worried about bandwidth though, and the dataset is extremely large, re-bind on each page load.

    What are you trying to do though, which made you ask such a wokaic question?

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