I have an application that allows a user to search a SQL database for a store. The user types in a store name and clicks a button and another, seperate form pops up with a list of stores that match the name that was entered. The user can select one of the stores and the popup form closes and a grid on the main form is populated with data from the database about that store. This is all powered through calling stored proceedures on the SQL server rather than using a dataset and it works without issue. The problem I have is when the user edits a cell in the grid.
I have a RowEditTemplate set up in modal for the grid because the stored procedure gives back more information than the user needs to see, and they are only allowed to edit a few of the fields that they can see. When they click on a cell, the RowEditTemplate pops up and they can make and save their changes. I've added code to the save button to call an update stored procedure and populate the paramters for the procedure. This all works fine as well.
The problem is that when the user searches for another store, then the RowEditTemplate no longer works! Even if they select the same store from the search box! I've stuffed a msgbox into BeforeRowEditTemplateDisplayed to let me know when it is called, and it is not called after the user performs their second search. I have the grid setup to show the RowEditTemplate when the cell changes (OnCellChange), but for some odd reason, it does not want to dispaly the template after the second search is performed by the user.
Any thoughts as to why this might be occuring?
I understand that is the problem, but I'm afraid I really don't know why this could be happening, though you might want to check to make sure that a given row's RowEditTemplateResolved (or the band's RowEditTemplate) is not null after rebinding the grid, which could happen if for whatever reason the data structure has changed, or the Key of the band is no longer the same (though this doesn't seem to be the case if it happens with the same store). Your best bet is definitely to submit a sample to Developer Support at this point, since I'm not sure if the problem can be tracked down without being able to see what's going on.
-Matt
I had the RowEditTemplate wizard create an OK and Save button for me. However, I did add additional code to the OK button's Click event to grab static data from the grid and edited data from the template to feed back into a stored procedure which is then executed (via ExecuteNonQuery method of SqlCommand object) to update the database. The last line of the button code is: Me.u_grdStoreData.Close(True)
Now, this works to allow the user to make as many updates to as many rows/cells as they desire on the first store that the bring up. The changes do indeed get back to the database, and the template opens as soon as they click on a cell and closes whenever they hit the OK or Cancel button.
The problem occurs when they bring up a second store for editing; the RowEditTemplate no longer works. If I/they close the app and re-run it, the first store brought up works as it should, but the template stops working when the search function is used a second time, even if it's used to bring up the same store!
It's quite maddening!
Are you certain that the RowEditTemplate has been closed? What are you trying to use to tell the grid the template is available? Did you try the Close method?
Thanks, Matt. The grid is populated by calling a stored procedure through a SQLDataAdapter and filling a DataSet with the returned rows. A DataView is then used to expose the DataSet, and I use the SetDataBinding method of the ultragrid to bind the DataView to the grid.
When the user performs a search, the same proceedure is used to re-populate the grid with the data for the new store. Should I maybe try and issue an "end edit" command after the grid is bound to try and convince it that the RowEditTemplate is again available for use?
*** EDIT ***
I tried to issue a row update cancel after the grid is filled, but this did not resolve the issue.
Unfortunately it's really hard to say what might be going on based on your description. If the data source that the grid is bound to changes (and here I'm a little confused, since the grid must be bound to *something*), the RowEditTemplate should be closed automatically as it is no longer associated with a row that is being edited. You can best think of the RET as hosting all the grid's editors on another form, but strongly tied to the ActiveRow of the grid. It sounds like the grid either thinks that the template is already open, or somehow the template has become disassociated from the grid.
Your best bet is to submit a small sample to Developer Support so that they can look into it, or have a developer review the issue.