|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
No Solution still for Saving DataView back to DataSet?figure out how to do it. I have a dataset name ds (typed dataset), side that ds contains a table name Employee. ds.Tables["Emploee"].Columns["City_Fk"] ex.say this table contains 50 records, and 10 records has City_Fk = 4 Say i want to make a view only for a certain city, now all the city. So i have something like this (this is all type in, might be typo error) DataView dv = new DataView(); dv.Table = ds.Employee.DefaultView; dv.RowFilter = "City_Fk = 4"; i got the dv.Count = 10 alright, but how come dv.Table.Rows.Count still = 50, why doensn't the table filter out also. (but that's one of my confusion) ok so now i have the dv contains 10 records like i wanted, but how do i put this 10 record in the ds.Emploee now?, i don't want the ds.Employee holding 50 records, i only want it to hold what ever the returns records from the dataview. I have done lots of research but could'nt get any answer :( please help! i even tried ds.Employee.DefaultView.RowFilter = ""City_Fk = 4"; but the ds.Employee.Rows.Count still = 50. Didn't understand what this rowfilter suppose to do, it seems like it didn't filter anything for me. Any help or suggestion is greatly appreciated. i'm in a tight deadline :( thanks in advance.Kim I even was thinking about looping through the dv.Table and add the
record into a Datatable and then later add this new datatable back into the ds, but then dv.Table holds 50 records, basically the table hold exactly whats on the ds, it's not holding the filtered data :( please help thank you A data view can be customized (using the RowFilter property) to presents a
subset of the data from the underlying data table. Although the underlying data table still has 50 rows the data view only displays 10. The Count property on the data view gets the number of records in the data view after the row filter and row state filter have been applied. The underlying data table exposed by the Table property and its rows collection Count property returns the total number of rows as one would expect. Copy each view-row into a new table (based upon the employee schema) and use that to compose a new dataset. DataTable employeesClone = employees.Clone(); foreach (DataRowView employee in employees.DefaultView) { employeesClone.ImportRow(eemployee.Row); } newDataSet.Tables.Add(employeesClone ); Best regards, Paul Gielens Visit my blog @ http://weblogs.asp.net/pgielens/ ### |
|||||||||||||||||||||||