• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1826
  • Last Modified:

Filter DataGridView

I have 3 textboxes & a DataGridView. When the user type text into the text box the DataGridView must filter base on the text typed. Im using linq to get the results to the DataGridView.
0
u2envy1
Asked:
u2envy1
  • 3
  • 3
1 Solution
 
DhaestCommented:
Same issue can be found here: http://www.techtalkz.com/c-c-sharp/372461-datagridview-linq.html

Datagridview allowing column selection and filtering
http://www.codeproject.com/KB/grid/GridFilter.aspx
0
 
u2envy1Author Commented:
They talk about LINQ to DataSets. Any example on this. Microsoft has it but I cant seem to find the FillDataSet(ds) method.
' See the FillDataSet method in the Loading Data Into a DataSet topic.
http://msdn.microsoft.com/en-us/library/bb552415.aspx
0
 
DhaestCommented:
The filldataset is the code you can find here: Loading Data Into a DataSet
http://msdn.microsoft.com/en-us/library/bb399340.aspx

(it's just creating a small datatable with data as an example)
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
u2envy1Author Commented:
How do I add a linq query to a SqlDataAdapter ? I need all communication to the DB in Linq.
0
 
DhaestCommented:
0
 
u2envy1Author Commented:
This is what I would like to do......
using (EmployeeDataContext empCtx = new EmployeeDataContext(GlobalMethods.SqlConnectionString))
            {
                var rsEmp = from emp in empCtx.Employees
                                          join payp in empCtx.PayPeriods on emp.PayperiodID equals payp.PayPeriodID
                                          join rst in empCtx.Rosters on emp.RosterID equals rst.RosterID
                                          join dep in empCtx.Departments on emp.DepartmentID equals dep.DepartmentID
                                          join div in empCtx.Divisions on emp.DivisionID equals div.DivisionID
                                          join cst in empCtx.CostCentres on emp.CostCentreID equals cst.CostCentreID
                                          join grp in empCtx.Groups on emp.GroupID equals grp.GroupID
                                          where emp.OrganizationID == UserClass.OrganizationID
                                          orderby emp.EmployeeNumber
                                          select new
                                          {
                                              emp.EmployeeID,
                                              emp.EmployeeNumber,
                                              emp.EmployeeName,
                                              emp.Surname,
                                              emp.BadgeNumber,
                                              payp.PayPeriodName,
                                              rst.RosterName,
                                              div.DivisionName,
                                              dep.DepartmentName,
                                              cst.CostCentreName,
                                              grp.GroupName,
                                              emp.EmploymentStatus,
                                              emp.EndOfEmployment
                                          };
                DataTable myTable = (DataTable)rsEmp;
                DataView filteredData = new DataView(myTable);
//Or
//OR
 
DataTable myTable = rsEmp.CopyToDataTable();
 
dataGridView1.DataSource = myTable ;
 
         
            }

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now