VB-APP: Program freezes when assigning a new datatable to the datagridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nev
    Contributor
    • Oct 2007
    • 251

    VB-APP: Program freezes when assigning a new datatable to the datagridview

    Happy Easter to all!

    I have a problem with a datagridview. I placed code in a button click event as follows:

    Code:
    dim dtt as datatable = dataset.employees.copy
    dtt.DefaultView.RowFilter = "[Last Name]='" & Me.LastNameTextBox.Text & "'"
    Me.DataGridView.DataSource = ""
    Me.DataGridView.DataSource = dtt
    When I run the program, I will be able to filter the datagridview by entering the lastname in the textbox then click the button. But, it only works twice. The third time I enter a new last name in the textbox and click the button, the program will freeze. I was expecting the code to work since I am assigning a new datatable for the datagridview everytime I click the button.

    Any help will be very much appreciated. Thank you.

    UPDATE 1:
    I have traced the problem in the statement:
    Code:
    Me.DataGridView.DataSource = dtt
    Does this mean that the way I am removing the datasource as...
    Code:
    Me.DataGridView.DataSource = ""
    is incorrect? If so, how should this be done? Thank you.

    UPDATE 2:
    Hi, I've tried declaring dtt like this but it didn't work...
    Code:
    dim dtt as new datatable
    dtt = dataset.employees.copy
    Last edited by nev; Mar 24 '08, 07:21 AM. Reason: Update & Findings
  • nev
    Contributor
    • Oct 2007
    • 251

    #2
    Any help here? Or any links that anyone can share?

    UPDATE 3:
    I noticed that the code works (I think). I noticed that the first time I clicked the button it assigns dtt to the datasource pretty fast. The next clicks I do to filter tend to slow down the assigning of dtt as the datasource. Hence, the program not responding. Does anyone know a correct workaround for this? Or any links that explains this behavior? Thank you very much.

    UPDATE 4:
    Any help here? I'm still stuck at this problem. Thanks.
    Last edited by nev; Mar 24 '08, 09:50 AM. Reason: Update & Findings

    Comment

    Working...