Filtering Data in a datagridview using visual studio 2005 ( help for a newbie

Posted on 2009-02-16
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"


        End If

    End Sub

Open in new window

Question by:djp12345
    1 Comment
    LVL 83

    Accepted Solution

    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 & "'"

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now