문제

I have this form on an application that I created the controls (textboxes) by dragging and dropping an employeemaster datasource onto the the form.

enter image description here

For now, the form works for all my needs for handling employees.

I have created a new field (business name) in my employeemaster table that I want to store the particular business associated with an employee. I now want to set a condition such that the form only loads with employees of a particular business set as a variable.

How do I filter the employee BindingSource to achieve this? Do I have to individually bind each control with a filter through code? I have not found much help on the internet.

도움이 되었습니까?

해결책

Depending on how much data you'll have in your database, you can do 1 of the following;

Either you filter on the datasource:

bsEmployee.DataSource.Filter = "AcolumnName like 'value'";

or you will make a sql query and add that to your TableAdapter, so that you will not load too much data into your application. (To add a parameterzied query go to DataSet designer,right click the TableAdapter you want to modify, and add a query. in the where statement you can write something like this " WHERE (columnName = @VariableName)"

taEmployee.FillByDepartment(datasetName.dataTableName, departmentNameVariable);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top