Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datatable select 1

Status
Not open for further replies.

Badgers

Programmer
Nov 20, 2001
187
US
Hi

I have a datatable of which I want to filter, and bind one version to a repeater and the other version to another repeater.

I wrote this func:



* private DataTable SelectIntoDataTable(string selectFilter, DataTable sourceDataTable)
* {
*
*
* DataTable newDataTable = sourceDataTable.Clone;
*
* DataRow[] dataRows = sourceDataTable.Select(selectFilter);
*
* // Declare a variable of type DataRow named typeDataRow.
*
* DataRow typeDataRow = default(DataRow);
*
* // Use the typeDataRow to loop through the rows of the sourceDataTable.
*
* foreach (var typeDataRow in dataRows) {
*
* newDataTable.ImportRow(typeDataRow);
* }
*
*
* return newDataTable;
*
* }


But this don't work, any ideas how to import the back into a datatable.

Thanks

inadvance.
 
do you mean you want to filter the data and bind to 1 object, then filter again and bind to another object?

if so you will need to create copies of the tables. 1 for each "view". there are a couple of ways to do this.

i would create dataview and use the ToTable() member to return a new table.

or just bind the controls to a dataview insetad of the acutal table.

thiscontrol.DataSource = new DataView(table, "filter");
thatcontrol.DataSource = new DataView(table, "filter");

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top