Results 1 to 5 of 5

Thread: Copying a datasource()

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Copying a datasource()

    I bind a table to a drop down called "ddList".
    I now want to make a table = the datasource of the "DDList".

    Is this possible ?

    Parksie

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Datasource properties take an object (probably reference)...

    So if you were to assign a datasource to a dropdownlist and your other table in a fell swoop like so...

    VB Code:
    1. Dim copyDataTable As DataTable
    2.     copyDataTable = myDataTable.Copy()
    3.  
    4. me.dropdownlist1.datasource = myDatatable
    5. me.dropdownlist1.databind

    you should be ok..

  3. #3

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    Does copying the table also copy all the rows ?

    Parksie

  4. #4
    Addicted Member rdove's Avatar
    Join Date
    Dec 2002
    Location
    Indianapolis
    Posts
    251
    I believe the Copy method only copies the data structure, I don't think it copies any of the data over.

    My question would be why are you want to get the datasource of ddlist when you have already got the original datatable in memory?

    If you are wanting to access the datatable outside the original function/procedure/event then why not declare it as public (if on webform) or pass it to the function.
    ~Ryan





    Have I helped you? Please Rate my posts.

  5. #5
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    DataTable.Copy copies both the schema and the data.

    But along the lines of what rdove suggested... not declaring it public of course...

    If the original datasource is a table... you could set both objects to the same table. However, if ones changes the underlying table, then a copy is of course recommended if you do not want changes to appear in both places.

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