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 ?
Printable View
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 ?
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:
Dim copyDataTable As DataTable copyDataTable = myDataTable.Copy() me.dropdownlist1.datasource = myDatatable me.dropdownlist1.databind
you should be ok..
Does copying the table also copy all the rows ?
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.
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.