?
Solved

Filtering Data in a datagridview using visual studio 2005 (vb.net) help for a newbie

Posted on 2009-02-16
1
Medium Priority
?
285 Views
Last Modified: 2012-05-06
I am below a novice at this so the easier the explaination and steps the better. I am creating a vb .net form using visual studio 2005. I created a datagridview (datagridview1) that attaches to my erp database as readonly (ms sql2000). The grid contains a query (code not shown) that populates information correctly. From there I created a combo box that will filter the data in the grid (see code). The problem that I have is when I filter the data, it will show me all the records in the grid for that PO and what I want to do is be able to filter records based on multiple criteria. As an example I select the PO in my combobox. It returns all records based that PO. Now what would like to do is create two text boxes (unbound I'm guessing) and filter the grid further based on a date in my grid called Receiver_Date. So I would select a PO from my first combbox(record filter) then put in the through and from dates. The other issue I am have is currently in my Receiver_Date field on the grid the returned records currently show up as date time (ex: 12/29/2008 11:40 am) I just want the date to show up with out the time and cannot find where to do this. Sorry if I rambled. I hope my explaination makes sense. Also please let me know if there is anything else I need to watch out for.
'Filter Data by PO
If ComboBox1.SelectedIndex > 0 Then
            Me.POIBindingSource.Filter = "PO_Name = '" & ComboBox1.SelectedValue.ToString & "'"
            Me.POIBindingSource.Sort = "PO_Name, Item_Name, Purchase_Order_ID"
            Me.POITableAdapter.Fill(Me.IERP81_TMADataSet.POI)
        End If
    End Sub

Open in new window

0
Comment
Question by:djp12345
1 Comment
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 225 total points
ID: 23657627
You have to play with this line

Me.POIBindingSource.Filter = "PO_Name = '" & ComboBox1.SelectedValue.ToString & "'"

If you need to filter on date then
Me.POIBindingSource.Filter = "PO_Name = '" & ComboBox1.SelectedValue.ToString & "' AND PO_Date>'" & txtdate.value & "'"
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

755 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