My Problem: The update command (and insert command) is not refreshing the grid. I have a problem with both insert and update, but for this post lets just focus on update.
My Code:
I have a data grid (residing on a tab).
I am using InLine Edit Mode, with no column templates.
When the user edits the row and later clicks the Update command, I execute my OnUpdateCommand() method. In this method, I successfully pull the user inputs, execute the SQL updates. All is good.
The inline edit, goes away, but the user does not see the data grid reflect the update.
Now the user can hit the refresh data grid command, and that will work.
I then attempted to execute the same refresh command after the OnUpdateCommand had done it's work, but still no grid refresh.
Why I am Picking-On the OnUpdateCommand:
OnUpdateCommand="grdAltProductCodes_UpdateCommand" |
I went to the grid's mark up, removed the OnUpdateCommand attribute. The result is that the user
- clicks edit
- changes text box data
- [I sneak over to the sql table and add/update 5 new records]
- clicks update command, [no sql update occurs cause we are not calling the OnUpdateCommand ].
- the data grid refreshes and the user sees the 5 updates I did directly to the database.
So everything is fine, till I attempt to use the OnUpdateCommand. Then no grid refresh.
So what does my OnUpdateCommand have to do, to force the data grid to refresh?
Is there a good, simple demo available? Everything I found was for the automatic updates.
Also, I did grabbed the latest code as of yesterday.
Thank You!
protected void grdAltProductCodes_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) | |
{ | |
AlternateProductCodeDC altProductCode = new AlternateProductCodeDC(); | |
//The GridTableView will fill the values from all editable columns in the hash | |
GridEditableItem editedItem = e.Item as GridEditableItem; | |
Hashtable newValues = new Hashtable(); | |
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem); | |
//Set Primary Key Stored as a Delimited Value within the Query String | |
string[] selectedRecord = Request.QueryString["i"].Split(','); | |
this._presenter.OnViewInitialized(Int32.Parse(selectedRecord[0]), selectedRecord[1], selectedRecord[2], selectedRecord[3], DateTime.Parse(selectedRecord[4])); | |
altProductCode.MasterCompanyId = Int32.Parse(selectedRecord[0]); | |
altProductCode.CountryCode = selectedRecord[1]; | |
altProductCode.Jurisdiction = selectedRecord[2]; | |
altProductCode.ProductCode = selectedRecord[3]; | |
//Read user values | |
altProductCode.AlternateProductCode = Convert.ToString(newValues["Alternate_Product_Code"]); | |
altProductCode.EffectiveDate = Convert.ToDateTime(newValues["Effective_Date"]); | |
if (newValues["Obsolete_Date"] == null) | |
{ | |
altProductCode.ObsoleteDate = null; | |
} | |
else | |
{ | |
altProductCode.ObsoleteDate = Convert.ToDateTime(newValues["Obsolete_Date"]); | |
} | |
//Have the presenter update the database | |
_presenter.OnAlternateProductCodeUpdate(altProductCode); | |
//Somehow get the datagrid to refresh itself | |
//RefreshGrid(); | |
//e.Canceled = false; | |
} |