// Open the database con. Open ();
// SQL statement
String oSql = "select id, name, station, level, dept from verify ";
// Extract data from the database
SqlDataAdapter da = new SqlDataAdapter (oSql, con );
// Create a set object
DataSet ds = new DataSet ();
// Load the extracted data from the database to the record set
Da. Fill (ds, "verify ");
// Close the database
Con. Close ();
// Obtain the table object from the record set
DataTable dt = ds. Tables ["verify"];
// Set the condition string to be filtered
String filterExpression = "dept = 'group '";
// Set the fields to be sorted and the sorting method string
String sortExpression = "name DESC ";
// Set row state filtering to the original row
DataViewRowState
RowStateFilter = DataViewRowState. OriginalRows;
// DataView dv = new DataView (dt, filterExpression, sortExpression, rowStateFilter );
// Create a DataView object and PASS Parameters to its constructor
// Set the attributes of Table, RowFilter, Sort, and RowStateFilter after DataView is generated.
// Step-by-step settings
// Create a DataView object
DataView dv = new DataView ();
// Obtain data
Dv. Table = dt;
// Set filter attributes
Dv. RowFilter = filterExpression;
// Set the sorting attribute
Dv. Sort = sortExpression;
// Perform Filtering
Dv. RowStateFilter = rowStateFilter;
// Cyclically retrieve filtered data and output it on the page
Foreach (DataRowView drv in dv)
{
For (int I = 0; I <drv. Row. Table. Columns. Count; I ++)
{
Response. Write (drv [I] + "<br> ");
}
}