Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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);

}

Posted

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");
}
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...