DataTable.Select()
will filter the rows based on the filter expression.
dt.Select("State='Andhrapradesh'") will return the
rows which is having state = 'Andhrapradesh'
Source Code:
DataTable dt = new DataTable("ResultSet");
dt.Columns.Add("Country");
dt.Columns.Add("State");
dt.Columns.Add("Place");
dt.Rows.Add("India", "Andhrapradesh", "Charminar");
dt.Rows.Add("India", "Andhrapradesh", "Steel Plant");
dt.Rows.Add("India", "Maharastra", "IT
Hub");
dt.Rows.Add("India", "Tamilnadu", "Beach
House");
dt.Rows.Add("India", "Tamilnadu", "Club
House");
dt.Rows.Add("USA", "Dallas", "Airport");
dt.Rows.Add("Australia", "Sydney", "Stadium");
DataRow[] arydr = dt.Select("State='Andhrapradesh'");
DataTable dtStates = dt.Select("State='Andhrapradesh'").CopyToDataTable();
Output of DataTable dtStates = dt.Select("State='Andhrapradesh'").CopyToDataTable();
