Hey all, just beginning to pick up some C# and I was wondering how to query data from a Data set in Visual Studio.

I'm setting my frame up like a form where it will show values from the database. I've got BindingNavigator to work properly (mainly because it does all the work for you) but I'm trying to figure out how to jump to a specific record via a button/link.

Example:

EMPLOYEES
------------------------------
EMPLOYEE_ID | EMPLOYEE_NAME
001           Devin
002           Nick
003           Patrick

If I were to click on a link titled "Devin" on my form, I'd like all the information found in the EMPLOYEES table for "Devin" to be displayed in there respective objects on the form.

Ideas?

Also, it'd be neat to have a dynamic TreeView of all the employee names. Essentially get amount of records and create a button for each employee record in the TreeView.

Make Sense?

Edited 6 Years Ago by SacredFootball: n/a

I think the grid view and detail view should do this for you. Check those controls out.

What/where are those? I cannot find them in the toolbox.

Ah sorry, I was thinking ASP.NET.

There is a DataGridView in WinForms though. Under the Data Controls section in the toolbar.

Ah sorry, I was thinking ASP.NET.

There is a DataGridView in WinForms though. Under the Data Controls section in the toolbar.

That's close but nt what I need. That's like putting data into a DB. It needs to be more user friendly so I'm trying to bind the columns to textboxes, labels, etc.

You could roll your own user control with data binding capabilities.

I've gotten that (sort of running into a couple kinks I'll need to figure out). Is there a way to click a button and have a it load certain data? I already have the navigation buttons to switch between records but having the ability to jump to a specific record by clicking a button would be a huge win.

Thanks for all your knowledge so far :)

The BindingNavigator doesn't seem to have a seek, find or search method. But, you can easily create a loop to find the record.

Without seeing code it's hard to give you examples, but something like:

Have your button pass a unique id identifying the record to a method.

The method starts at MoveFirstItem and checks the id for a match, using MoveNextItem until a match is found.

This article has been dead for over six months. Start a new discussion instead.