Re-Loading DataGrid
Re-Loading DataGrid
Re-Loading DataGrid
Re-Loading DataGrid
Re-Loading DataGrid
Re-Loading DataGrid Re-Loading DataGrid Re-Loading DataGrid Re-Loading DataGrid Re-Loading DataGrid Re-Loading DataGrid Re-Loading DataGrid Re-Loading DataGrid
Re-Loading DataGrid Re-Loading DataGrid
Re-Loading DataGrid
Go Back  Xtreme Visual Basic Talk > > > Re-Loading DataGrid


Reply
 
Thread Tools Display Modes
  #1  
Old 02-10-2015, 08: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 08:54 PM.
Reply With Quote
  #2  
Old 02-12-2015, 07:54 AM
CharlieMay's Avatar
CharlieMay CharlieMay is offline
Regular
 
Join Date: Sep 2009
Location: Indiana
Posts: 89
Default

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 = ""
__________________
I thought I knew what I was doing...
...And then I turned on Option Strict

Last edited by CharlieMay; 02-12-2015 at 08:14 AM.
Reply With Quote
  #3  
Old 02-17-2015, 02:29 PM
supercrewed supercrewed is offline
Centurion
 
Join Date: Feb 2004
Posts: 152
Default

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


Code:
SalvageBindingSource.Filter = (vbNullString)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Re-Loading DataGrid
Re-Loading DataGrid
Re-Loading DataGrid Re-Loading DataGrid
Re-Loading DataGrid
Re-Loading DataGrid
Re-Loading DataGrid Re-Loading DataGrid Re-Loading DataGrid Re-Loading DataGrid Re-Loading DataGrid Re-Loading DataGrid Re-Loading DataGrid
Re-Loading DataGrid
Re-Loading DataGrid
 
Re-Loading DataGrid
Re-Loading DataGrid
 
-->