[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Filter DataGridView

Posted on 2009-02-19
6
Medium Priority
?
1,810 Views
Last Modified: 2012-05-06
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
Comment
Question by:u2envy1
  • 3
  • 3
6 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 23689721
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
 

Author Comment

by:u2envy1
ID: 23689751
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
 
LVL 53

Expert Comment

by:Dhaest
ID: 23689796
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:u2envy1
ID: 23689825
How do I add a linq query to a SqlDataAdapter ? I need all communication to the DB in Linq.
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 2000 total points
ID: 23689903
0
 

Author Comment

by:u2envy1
ID: 23689986
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month19 days, 9 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question