Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid not refresh

Status
Not open for further replies.

spidervenom

Programmer
Mar 8, 2003
19
0
0
US
Hi all,

I am using VB.NET and trying to remove. I have 2 forms (Form1 and Form2). When user clicks "Edit" button in Form1, Form2 will open.

Inside Form2, there is a list of Customer displays in a Datagrid control. When the user highlighted the current row, and click the "Remove" button on the form, the datagrid will remove the 1st Customer from the list (This works so far using RemoveAt()). The user then repeats the steps to highlight the row and click "Remove" to delete the 2nd and 3rd customer 1 by 1. When finish, the user click "Done" to return to Form1.

However, when clicking "Edit" again to go back into Form2, I notice that only the 1st Customer is remove from the Datagrid, but the 2nd and 3rd customer is still displaying in the Datagrid.

What I am expecting is when I return to Form2, all 3 Customers should not be displayed in the Datagrid. All I want is to remove the Customers from the DataTable, not sending any updates to affect the underlying Database.

In the "Done" button Click event, I tried to assign the updated DataTable (with the Customer deleted) to DataSource, and then perform a Datagrid Refresh(). I am still having the same problem.

Can anyone let me know how I can solve this problem?

Thanks a lot!!!
 
Could you post your code that deletes the records from the datagrid/datatable?


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
*********Here is the Remove Button code:

*********resultSet is a DataTable

Private Sub btnRemove_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRemove.Click

If resultSet.Rows.Count < 2 Then
MsgBox("At least one Customer is required")
Else

resultSet.Rows.RemoveAt(dgContactList.CurrentRowIndex)

End If

End Sub

*******Here is the code for the Done button:

Private Sub btnDone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDone.Click


Me.Close()

End Sub

This will delete the current row (current Customer) one by one from the datagrid. It remove the row right away from the datagrid.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top