Click here to Skip to main content
15,883,623 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a Data Table, which contain ID 1,2,3,5,8 & Text 'A','X','T' so on
I want to filter Data Table in such a way that it should remove where ID 2,5
Posted
Updated 22-Aug-13 23:55pm
v2
Comments
Shambhoo kumar 23-Aug-13 6:06am    
please Elaborate your question..
Mukesh Ghosh 23-Aug-13 6:30am    
Current Data Table, which contain ID 1,2,3,5,8 & Text 'A','X','T'
After Filter Same Data Table should not contain 2,5

1 solution

try this from data table use data column and compare values and copy the values except those you want to remove
C#
 DataTable DataTablecase = new DataTable("count");
 da4.Fill(DataTablecase);
 DataColumn dc6 = DataTablecase.Columns[0];
 DataColumn dc7 = DataTablecase.Columns[1];
 if (DataTablecase.Rows.Count > 0)
 {
   foreach (DataRow row1 in DataTablecase.Rows)
   {
     if((Convert.ToInt32(row1[dc6])!=2)||(Convert.ToInt32(row1[dc6])!=5))
     {
        //declare the array and i
        a[i]=Convert.ToInt32(row1[dc6]);
        b[i]=(row1[dc7].ToString())
        i++;
     }
   }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900