Hi Team
Please help me to resolve my issue with gridview refresh.
I am using ULTRAGRID View for displaying user information. There is a tabbed manager control in my MDI form
The user details screen is having Add user toolbar. When clicked on this it will open another tab for adding user. When the user is added to the db, onclosing event of this form I am refreshing the user details screen (ie re binding the data from db.) but the data inside the gridview is not reloading (not able to see the newly added record)
I am using VB.net
//User Add formclose event.
Private Sub frmUserAdd_FormClosing(sender As System.Object, e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
Using frmU As New frmUser
frmU.RefreshGrid()
End Using
End Sub
//Below is the code for Gridview details page refreshGrid
Public Sub RefreshGrid() Try Dim RmUser As New RateMappingUser() Dim ds As New DataSet RmUser.connectionString = gHiveConnectionString ds = RmUser.GetAllUsers() grdAllUsers.DataSource = ds.Tables(0) If grdAllUsers.Rows.Count > 0 Then grdAllUsers.Rows(0).Selected = True End If CommonSettings.SetGridSettings(grdAllUsers) Catch ex As Exception Using frmErr As New frmException(ex.Message, ex.InnerException.ToString()) frmErr.ShowDialog() End Using End Try End Sub End Class
Thanks in advance
Hi,
There's really no enough information here for me to go on. I don't know what most of these objects are, so there's no way for me to even guess what this code is supposed to do.
For what I can see, if looks like you are creating a form that gets the data from the data base and creates a new DataSet. And then presumably your users are modifying that data set, but this will not have any effect on the back end you somehow commit those changes. And the you could will have to update the existing DataSet (or whatever data source you are using) for your user information screen.
Maybe I am wrong, but if that's what you are doing, it's a very convoluted and different way to achieve what you want. It would be a lot easier to use the existing DataSet you already have in memory instead of going back to the DataBase.
Hi Mike
I willl rephrase my question for your understanding
I am filling the ultra grid with a dataset and this screen is opened by the user. There is another screen which is opened in tabbed view and some data is modified (underlaying table is same for grid and this screen). How should I refresh the ultra grid when the modified screen is closed.
I tried to use Refresh method of the grid but it was not given the expected result.
There are three layers here: The grid, the DataSource, and the DataBase. your posts aren't making a clear distinction between the local data source (the grid's DataSource property) and the DataBase (the back end). When you say "underlaying table is same for grid and this screen" are you talking about the back end or the data source of the grid?
If you are using the same data source for both grids (A DataSet, perhaps), then you would not need to do anything at all. The DataSet will send a notification when anything changes and the grid will detect this.
It sounds to me like you mean the back end. In which case, you would have to refresh your local data source to pick up the changes first, before the grid could possibly do anything. But I could be wrong, because it's still not really clear to me what the situation is.
If you have already refreshed the grid's data source and the grid is still not displaying the new data, then the only explanation is that your data source is an IList instead of an IBindingList and therefore doesn't send the proper notifications. In which case, you could force the grid to refresh the data by calling:
grid.Rows.Refresh(ReloadData, true);