Display Record in DataGridView Based on ComboBox Selected Value
In this tutorial I will teach you on how to display related record based on the selection value from a ComboBox.
The example displays a student’s subject in a DataGridView after a SelectedIndexChanged event of a ComboBox.
This tutorial assumes that you already know how to add a DataSet in your project.
The following are important steps in order to understand how I made this simple program.
1. Bind a ComboBox
[inline:ComboBox_Data_Binding.jpg=Bind a ComboBox]
2. Add a query in the Course Table under DataSet designer
[inline:DataSet.jpg=Add a query in the Course Table under DataSet designer]
3. Edit DataGridView columns after binding from Data Source
[inline:Edit_Columns.jpg=Edit DataGridView columns after binding from Data Source]
4. Select only the following field by removing unnecessary columns
[inline:Columns.jpg= remove unnecessary columns]
5. In the SelectedIndexChanged event of the ComboBox use the FillBy method instead of Fill method
[inline:FillBy.jpg=FillBy method]
As you can see in the DataSet designer there are two fill method in a Course table name Fill and FillBy. FillBy has a parameter named StudentID. This will tell our TableAdapter to filter the record using the FillBy method.
Comments
Display Record in DataGridView Based on ComboBox Selected Value
One of the approach if you
One of the approach if you
Sir Jay
re: Sir Jay
re: Sir Jay
Get value from database based on combox
vb and oracle
How to make design
Hé This is a great example
More A tutorilas
Problem with second step
Is your problem resolved?
Are you using MS Access
Space in the field name
Display record according to ComboBox selection in CSharp .NET
sales force system
Add new comment
- Add new comment
- 555 views