Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
295
UltraGrid Cell Values not Changing when trying to Save Data
posted

I'm trying to save the updated values of an UltraGrid, and I have one variable for each column in the grid. Despite calling ugModules.Update(), and updating the row that is being iterated over, the variable values are not reflecting the new values in the grid, they're always holding the values of the original data.

I also have the UpdateMode to OnUpdate in InitializeLayout, but they just aren't updating.

The grid DataSource is a DataSet that I created after running a Select query, if that helps?

This is the code:

ugModules.UpdateData()

Dim mID As Integer = 0
Dim mName As String = ""
Dim numUsers As String = ""

For Each ugr As UltraGridRow In ugModules.Rows
ugr.Update() 

mID = ugr.Cells("ModuleID").Value
mName = ugr.Cells("ModuleName").Value
numUsers = ugr.Cells("NumberUsers").Value

Yet, those variables are always reflecting the old values. I've also tried without ugr.Update(), but that made no difference?

Parents
  • 469350
    Offline posted

    Hi,

    I'm a little confused by what you want here, but the property setting you are using seem to be the opposite of what you are trying to achieve.

    It's not clear from your description exactly what changes you are making to the cell values or how you are making them. Are you setting the Value of a cell in code? Are you making changes by typing or otherwise choosing a value for the grid cell through the UI?

    The Value property of a cell returns the value from the underlying data source - in this case, your DataSet. So if you enter edit mode on a cell and start typing, the Value will be the old value. If you want the text on the screen you would have to use the Text property of the cell.

    The changes to a cell normally get committed to the data source when the user either leaves that cell or loses focus on the grid. But this is controlled by the UpdateMode property and since you change it to OnUpdate, it will not happen until you call UpdateData or until the BindingManager position changes. To be totally honest, the OnUpdate setting doesn't really work correctly. It was carried over from ActiveX and it's not actually a viable setting in DotNet. But it seems like the opposite of what you want, anyway. So I would not recommend using it.

    Also... and maybe this is just a typo, but you mentioned calling ugModules.Update(). The actual code example is calling UpdateData. These methods are not the same thing. Update just forced a paint and will not have any effect on your data or it's commitment to the data source. UpdateData is the correct method to force the data to be committed to the Data Source.

Reply Children