Problem with datatable
-
Hi, I have a datatable which is going to fill from a if statment (I mean I don't know which record is going to returned) and after the data is returned i want to be able to edit or delete the returned records. (the IF's are a search statment all on one table and diffrent columns) so when S.O wants to delete a record i want to refresh the Grid which is filled with datatable. how can i refresh the datatable. (I hope i was able to express what I mean) please help me.:D
-
Hi, I have a datatable which is going to fill from a if statment (I mean I don't know which record is going to returned) and after the data is returned i want to be able to edit or delete the returned records. (the IF's are a search statment all on one table and diffrent columns) so when S.O wants to delete a record i want to refresh the Grid which is filled with datatable. how can i refresh the datatable. (I hope i was able to express what I mean) please help me.:D
I strongly advise to use SQL to get only the data you want. If this is not possible you will have to use loop to step through all returned rows and fill a new DataTable with only the rows you want (ImportRow) (no a DataView won't help if you can't use SQL to filter). If you may use LINQ it's getting simpler - just use where with your IF (for example:
var FilteredDT = from c in originalTable where (c => (statements from the if for c - for example c.Name.StartsWith("x"))) select c;