Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET Database and Reporting (http://www.xtremevbtalk.com/-net-database-and-reporting/)
-   -   Re-Loading DataGrid (http://www.xtremevbtalk.com/-net-database-and-reporting/327493-re-loading-datagrid.html)

supercrewed 02-10-2015 07:29 PM

Re-Loading DataGrid
 
I'm trying to filter the data in a DataGrid, and it works! However, I cannot figure out how to reset the DataGrid, to show all of the data once it has been filtered.

If I could run the filter, remove the .MaterialSelect.text option, then I could reset the data, by applying a null value to any one of the other fields, and it works, but I'm confused, and I don't want to mess it up, since the program works. If I attempt to remove the .MaterialSelect.text field from the sort, I get a error, due to a mismatch of the data, due to the "String.Format" code. I hope this makes sense...

This is the code to filter the data, is here...

Code:

Private Sub Searchbtn_Click(sender As Object, e As EventArgs) Handles Searchbtn.Click

        With Me
            If Len(.HeightInput.Text) > 0 And Len(.MaterialSelect.Text) > 0 Then
                SalvageBindingSource.Filter = String.Format("[Material] = '{0}' AND [Height] >= {1}",
                                                        MaterialSelect.Text,
                                                        HeightInput.Text)
                Exit Sub
            ElseIf Len(.WidthInput.Text) > 0 And Len(.MaterialSelect.Text) > 0 Then
                SalvageBindingSource.Filter = String.Format("[Material] = '{0}' AND [Width] >= {1} ",
                                                        MaterialSelect.Text,
                                                        WidthInput.Text)
                Exit Sub
            ElseIf Len(.LengthInput.Text) > 0 And Len(.MaterialSelect.Text) > 0 Then
                SalvageBindingSource.Filter = String.Format("[Material] = '{0}' AND [Length] >= {1}",
                                                        MaterialSelect.Text,
                                                        LengthInput.Text)
                Exit Sub
            ElseIf Len(.MaterialSelect.Text) > 0 Then
                SalvageBindingSource.Filter = String.Format("[Material] = '{0}'",
                                                        MaterialSelect.Text)
            End If
        End With
    End Sub

This is the code to load the DataGrid, and tried running it, to reload the data, but with no luck, but I run this sub, on the Form.Load, works perfectly...

Code:

   
Private Sub FillData()
        With Me
            .DateInput.Text = DateTime.Now.ToString("MM/dd/yyyy")

            .SalvageTableAdapter.Fill(.SALINVDataSet.Salvage)

            .NotesTableAdapter.Fill(.SALINVDataSet.Notes)

            .MaterialTableAdapter.Fill(.SALINVDataSet.Material)

        End With
    End Sub


CharlieMay 02-12-2015 06:54 AM

Haven't delved deep into this but have you tried just submitting a blank filter to the bindingsource's filter?

I'm pretty sure that when you try FillData again, it's running off the last filter that was set in the BindingSource.

Code:

SalvageBindingSource.Filter = ""

supercrewed 02-17-2015 01:29 PM

Man did I feel like a dummy, when I finally did, and of course it worked...


Code:

SalvageBindingSource.Filter = (vbNullString)


All times are GMT -6. The time now is 11:05 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.