Hi.
I have an interesting issue. I have an ASP.NET UpdatePanel on the page with a Timer in it that posts back every 15 seconds. Separately (outside the UpdatePanel), but on the same page, I have an editable UltraWebGrid. There is also a 'Save' button that allows the user to save all their changes to the records in the UltraWebGrid in one click. It loops through the rows and checks the DataChanged property to see if it's DataChanged.Modified. The problem is that if the user is editing several rows in the UltraWebGrid and the Timer causes a postback of the UpdatePanel, the UltraWebGrid seems to "forget" that some of the rows are Modified.
For instance: The user changes some data in rows 3, 4, and 5. The Timer causes a postback of the UpdatePanel. The user changes some data in rows 6 and 7. The user clicks 'Save'. Only rows 6 and 7 will be updated because the grid has "forgotten" that the other 3 rows were Modified.
Any advice / suggestions on this issue would be appreciated. The only thing I can think is to use Javascript to set a Hidden column to 'Modified' and loop through that column when the user clicks 'Save' rather than relying on the DataChanged property of the Row.
Also watch followings in the watch window.
Request["__EVENTTARGET"]Request["__EVENTARGUMENT"]Request["__CALLBACKID"]Request["__CALLBACKPARAM"]
Hi,
There is no way to prevent firing of InitializeDataSource. But inside the event you can make the processing conditioal.
And to know the condition, you need to identify the reason of InitializeDatasource. This event may fire because of various reason. Like Save button click, timer's tick , any other post back , grid event like sort, etc.
It is not difficult to identify the exact reason. We just need to check the Request variable.
My simple observation is, for all ajax call on the panel you will get (Request["HTTP_X_MICROSOFTAJAX"] != null) as false, it means that for all the AJAX call you will have Request["HTTP_X_MICROSOFTAJAX"] set to some value.
You can do detailed analysis by putting a break point in InitializeDataSource and watching following variables in watch window:
Once you have proper reason, you can skip the processing in the InitializeDatasource event.
---------------
For combo closing because of timer tick: you can cancel the AJAX call (Time tick event) when user is in edit mode of the combo. For this you need to do client side javascript programming.
Hi. Thanks again for the quick response.
My Grid is bound to a typed dataset that is loaded programmatically. I don't think the binding of the grid is the issue here. I believe it is related to the WebCombo. The WebCombo is filtered for each row on the grid using the BeforeEnterEditModeHandler. This seems to make a call to InitializeDataSource for the WebCombo. So each time the timer ticks, it is going into the InitializeDataSource of the WebCombo. Is there a way to prevent this? It also closes up the dropdown of the WebCombo if you happen to have it expanded when the timer ticks. Also, it seems to exit from edit mode if you happen to be in edit mode on any of the other cells when the timer ticks.
I really need this auto-refresh of the update panel, but it's starting to seem like more trouble than it's worth.
Do you have SQLDataSource control that is bound to the grid?
Or how do you bind data to the grid?
By Request[""] I mean to say:
whenever ASP.Net event occurs, it may be because of any action on the web page. The ASP.Net Request object contains the event detail (name of the sender), all current value on the form etc.
Using Request collection we can easily identify the cause of event. In your case if you use InitializeDatasource and if you are able to identify that the event is caused by timer then, by skipping databinding, you can preserve old values.
Hi. Thank you for your response.
I don't bind my grid in the InitializeDataSource event, but I do have a WebCombo that is the EditorControl for one of the columns and that is bound with an InitializeDataSource. Could that be causing the problem? I'm not sure what you mean by check the Request[""] variable.