I am developing from the demo you provided here: http://demos.telerik.com/aspnet-ajax/calendar/examples/datepicker/shareddatepicker/defaultcs.aspx?product=grid
In the OnItemCommand event handler I am looping through all the fields that have been changed and save or delete them when the "Update4 All" button is clicked. The problem is when the user clicks the "Add new Record" button. In the UI, the row appears and the user can add new values for each column. But when they click "Update All" this new row is not in the RadGrid1.Items collection. I would like to add this while I am updating and deleting the other rows. Is there a way to do this?
In the OnItemCommand event handler I am looping through all the fields that have been changed and save or delete them when the "Update4 All" button is clicked. The problem is when the user clicks the "Add new Record" button. In the UI, the row appears and the user can add new values for each column. But when they click "Update All" this new row is not in the RadGrid1.Items collection. I would like to add this while I am updating and deleting the other rows. Is there a way to do this?
| protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) |
| { |
| if (e.CommandName == "UpdateChanges") |
| { |
| ArrayList editedItems = new ArrayList(); |
| foreach (GridDataItem item in RadGrid1.Items) |
| { |
| if ((item is GridEditableItem) && (item.IsInEditMode)) |
| { |
| Hashtable ht = new Hashtable(); |
| //add in delete flag |
| ht["ShouldDelete"] = false; |
| if (item.Selected) |
| { |
| ht["ShouldDelete"] = true; |
| } |
| //add in read only columns |
| ht["ServerID"] = (item.EditManager.GetColumnEditor("ServerID") as GridTextBoxColumnEditor).TextBoxControl.Text; |
| if (item.Selected || presenter.ValuesChanged((string)ht["ServerID"])) |
| { |
| item.ExtractValues(ht); |
| //add in any template columns |
| ht["OrderDate"] = ((TextBox)(item.EditManager.GetColumnEditor("OrderDate") as GridTemplateColumnEditor).ContainerControl.FindControl("TextBox1")).Text; |
| editedItems.Add(ht); |
| } |
| } |
| } |
| if (editedItems.Count > 0) |
| { |
| presenter.UpdateAll(editedItems); |
| XmlDataSource1.Save(); |
| RadGrid1.Rebind(); |
| notificationDisplayMsg.NotificationType = Trizetto.Web.UI.Controls.NotificationType.Information; |
| notificationDisplayMsg.Text = "All changes have been saved."; |
| } |
| } |
| } |