Josh-CO Dev

Solving the worlds problems one line of code at a time.

.NET – Querying data from a binding source

Leave a comment

Rather than write code that is chatty with the database, it is possible to pull all the data that your user could ever need from a table or procedure and store it in a dataset. Normally you would then drop in a binding source to link up your datagrid and the dataset. In some cases, you may want to search the data in the grid to find a particular piece of data. Maybe you want to give your users the ability to enter a value in a search box and navigate directly to that record. Using the binding source, this is as simple as two lines of code.

Here it is:

int itemFound = bindingSource.Find(”Field”, Convert.ToInt32 (ValueToFind));

bindingSource.Position = itemFound;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s