or
protected void RadGrid1_RowDrop(object sender, GridDragDropEventArgs e) { GridDataItem dataItem = e.DraggedItems[0]; Hashtable values = new Hashtable(); dataItem.ExtractValues(values); (int)dataItem.GetDataKeyValue("ID"); string firstName = (string)values["FirstName"]; string lastName = (string)values["LastName"]; string targetSlotIndex = TargetSlotHiddenField.Value; if (targetSlotIndex != string.Empty) { HandleSchedulerDrop(id, firstName, targetSlotIndex); TargetSlotHiddenField.Value = string.Empty; } RadScheduler1.Rebind(); rgGridViewUsers.Rebind(); RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadGrid1, RadScheduler1); } private void HandleSchedulerDrop(int id, string subject, string targetSlotIndex) { RadScheduler1.Rebind(); ISchedulerTimeSlot slot = RadScheduler1.GetTimeSlotFromIndex(targetSlotIndex); TimeSpan duration = TimeSpan.FromHours(1); if (slot.Duration == TimeSpan.FromDays(1)) { duration = slot.Duration; } ScheduleAppointment(id, subject, slot.Start, slot.Start.Add(duration)); } private void ScheduleAppointment(int id, string subject, DateTime start, DateTime end) { IDataSource dataSource = SchedulerDataSource; DataSourceView view = dataSource.GetView("DefaultView"); IOrderedDictionary data = new OrderedDictionary(); data.Add("Subject", subject); data.Add("Start", start); data.Add("End", end); IDictionary keys = new OrderedDictionary(); keys.Add("ID", id); //keys.Add("ID", 234); view.Update(keys, data, new OrderedDictionary(), OnDataSourceOperationComplete); } private static bool OnDataSourceOperationComplete(int count, Exception e) { if (e != null) { throw e; } return true; }protected void RadGrid1_RowDrop(object sender, GridDragDropEventArgs e) { GridDataItem dataItem = e.DraggedItems[0]; Hashtable values = new Hashtable(); dataItem.ExtractValues(values); Guid id = new Guid((string)values["ID"]);//(int)dataItem.GetDataKeyValue("ID"); string firstName = (string)values["FirstName"]; string lastName = (string)values["LastName"]; string targetSlotIndex = TargetSlotHiddenField.Value; if (targetSlotIndex != string.Empty) { HandleSchedulerDrop(id, firstName, targetSlotIndex); TargetSlotHiddenField.Value = string.Empty; } RadScheduler1.Rebind(); rgGridViewUsers.Rebind(); RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadGrid1, RadScheduler1); } private void HandleSchedulerDrop(Guid id, string subject, string targetSlotIndex) { RadScheduler1.Rebind(); ISchedulerTimeSlot slot = RadScheduler1.GetTimeSlotFromIndex(targetSlotIndex); TimeSpan duration = TimeSpan.FromHours(1); if (slot.Duration == TimeSpan.FromDays(1)) { duration = slot.Duration; } ScheduleAppointment(id, subject, slot.Start, slot.Start.Add(duration)); }private void ScheduleAppointment(Guid id, string subject, DateTime start, DateTime end) { IDataSource dataSource = SchedulerDataSource; DataSourceView view = dataSource.GetView("DefaultView"); IOrderedDictionary data = new OrderedDictionary(); data.Add("Subject", subject); data.Add("Start", start); data.Add("End", end); IDictionary keys = new OrderedDictionary(); keys.Add("ID", id); //keys.Add("ID", 234); view.Update(keys, data, new OrderedDictionary(), OnDataSourceOperationComplete); } private static bool OnDataSourceOperationComplete(int count, Exception e) { if (e != null) { throw e; } return true; }| public void RadGrid_Saved(object sender, GridInsertedEventArgs e) |
| { |
| if (e.Exception != null) |
| { |
| e.KeepInInsertMode = true; |
| if (e.Exception.InnerException is ORMEntityValidationException) |
| e.ExceptionHandled = true; |
| } |
| } |
<XAxis DataLabelsField="ReceivedDate" Step="7"><telerik:RadGrid ID="dgData" runat="server" AllowFilteringByColumn="true" AllowSorting="True" AutoGenerateColumns="True" Skin="Web20" PageSize="500" GridLines="None" Width="945px" AllowPaging="True" TabIndex="-1" EnableEmbeddedSkins="true" OnBiffExporting="RadGrid_BiffExporting" Visible="false" HeaderStyle-Wrap="false"> <PagerStyle Position="Bottom" Mode="NumericPages" PageButtonCount="10" AlwaysVisible="true" /> <ClientSettings> <Scrolling AllowScroll="True" ScrollHeight="350px" UseStaticHeaders="true"></Scrolling> <Resizing ResizeGridOnColumnResize="True" ClipCellContentOnResize="False" /> </ClientSettings> <MasterTableView AllowMultiColumnSorting="True" EnableNoRecordsTemplate="False" GridLines="Vertical" DataKeyNames="ID"> </MasterTableView></telerik:RadGrid>