reagan123 Posted January 3, 2006 Posted January 3, 2006 I�m playing around with an ado.net windows form application and ran into a problem. I have a data set that is filled. I�m trying to use the select method on a dataset to filter some records� when I bind the results to the datagrid I�m getting extra columns in the grid like the follosing. HasErrors | RowError | Table | etc� What do I need to do in order to have it display just the columns from the dataset?. Here is the code. Thanks for any suggestions. try { dgLocations.DataSource = this.dsSoftwareLocations1.Tables["software"].Select("Software='" + this.cboSoftware.Text + "'"); // this.dgLocations.DataSource = this.dsSoftwareLocations1.Tables["software"]; } catch(Exception ex) { MessageBox.Show(ex.Message); } Quote
reagan123 Posted January 3, 2006 Author Posted January 3, 2006 Got it to work using the following. I'm still open to suggestions if there is a better way of doing this. try { // Apply Filter Expression this.dsSoftwareLocations1.Tables["software"].DefaultView.RowFilter = "Software='" + this.cboSoftware.Text + "'"; // Gets the number of records in the DataView after // RowFilter and RowStateFilter have been applied. if (dsSoftwareLocations1.Tables["software"].DefaultView.Count > 0) { dgLocations.DataSource = dsSoftwareLocations1.Tables["software"].DefaultView; } else { MessageBox.Show("Filter criteria does not meet criteria"); } } Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.