View Single Post
 
Old 02-10-2015, 07:29 PM
supercrewed supercrewed is offline
Centurion
 
Join Date: Feb 2004
Posts: 152
Default 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

Last edited by supercrewed; 02-10-2015 at 07:54 PM.
Reply With Quote