| <AppointmentTemplate> |
| (<asp:Literal ID="AppointmentStartTime" runat="server" Text='<%# Eval("Start", "{0:t}") %>'></asp:Literal> |
| - |
| <asp:Literal ID="AppoitmentEndTime" runat="server" Text='<%# Eval("End", "{0:t}") %>'></asp:Literal>) |
| <asp:Literal ID="AppointmentSubject" runat="server" Text='<%# Eval("Subject") %>'></asp:Literal> |
| </AppointmentTemplate> |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| if (!Page.IsPostBack) |
| { |
| this.loadGrid(); |
| } |
| } |
| protected void loadGrid() |
| { |
| // Get the null level codes and sort according to display order |
| dataset = controller.GetCode(null); |
| // Set the keys |
| RadGrid1.MasterTableView.DataKeyNames = new string[] { "code", "value" }; |
| RadGrid1.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client; |
| RadGrid1.ClientSettings.EnablePostBackOnRowClick = true; |
| //Column to use to create the RadGrid columns |
| GridBoundColumn boundColumn; |
| //code column |
| boundColumn = new GridBoundColumn(); |
| RadGrid1.MasterTableView.Columns.Add(boundColumn); |
| boundColumn.DataField = "code"; |
| boundColumn.HeaderText = "Code"; |
| boundColumn.HeaderStyle.Width = 80; |
| //value column |
| boundColumn = new GridBoundColumn(); |
| RadGrid1.MasterTableView.Columns.Add(boundColumn); |
| boundColumn.DataField = "value"; |
| boundColumn.HeaderText = "Value"; |
| boundColumn.HeaderStyle.Width = 80; |
| // Create dataset for sub level codes |
| subDataset = new DataSet(); |
| GridTableView subGrid = new GridTableView(RadGrid1); |
| subTypeCodeGrid.Name = "SubCodes"; |
| subTypeCodeGrid.DataKeyNames = new string[] { "code", "value" }; |
| subTypeCodeGrid.AutoGenerateColumns = false; |
| GridRelationFields relationFields = new GridRelationFields(); |
| relationFields.MasterKeyField = "value"; |
| relationFields.DetailKeyField = "code"; |
| subTypeCodeGrid.ParentTableRelation.Add(relationFields); |
| RadGrid1.MasterTableView.DetailTables.Add(subGrid); |
| // Add columns to sub dataset |
| //code column |
| boundColumn = new GridBoundColumn(); |
| subTypeCodeGrid.Columns.Add(boundColumn); |
| boundColumn.DataField = "code"; |
| boundColumn.HeaderText = "Code"; |
| boundColumn.HeaderStyle.Width = 80; |
| int gridWidth = 0; |
| for (int i = 0; i < RadGrid1.MasterTableView.Columns.Count; i++) |
| { |
| gridWidth += (int)RadGrid1.MasterTableView.Columns[i].HeaderStyle.Width.Value; |
| } |
| RadGrid1.Width = gridWidth + 30; |
| } |
| protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) |
| { |
| int index = e.Item.ItemIndex; |
| if ((e.CommandName == RadGrid.ExpandCollapseCommandName || e.CommandName == "RowClick")) |
| { |
| string Value = RadGrid1.MasterTableView.Items[index]["value"].Text.ToString().Trim(); |
| if (loadedValues.Contains(Value)) |
| { |
| return; |
| } |
| else |
| { |
| loadedValues.Add(Value); |
| DataSet tempSubCodes = controller.GetCode(Value); |
| foreach (DataSet.table1Row row in tempSubCodes.table1) |
| { |
| subDataset.table1.Rows.Add(row.ItemArray); |
| } |
| RadGrid1.Rebind(); //<-- ERROR |
| } |
| RadGrid1.MasterTableView.Items[index].Expanded = true; |
| } |
| } |
| protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
| { |
| if (!e.IsFromDetailTable) |
| { |
| RadGrid1.DataSource = dataset.table1.DefaultView; |
| } |
| } |
| protected void RadGrid1_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e) |
| { |
| switch (e.DetailTableView.Name) |
| { |
| case "SubCodes": |
| { |
| e.DetailTableView.DataSource = subDataset.table1.DefaultView; |
| break; |
| } |
| } |
| } |

grid.MasterTableView.EditMode =
GridEditMode.EditForms;
grid.MasterTableView.EditFormSettings.EditFormType =
GridEditFormType.AutoGenerated;
Whenever user attempts to Update a record that results in the exception, I handle the exception through ItemUpdated event:
| private static void grid_ItemUpdated(object source, GridUpdatedEventArgs e) |
| { |
| if (e.Exception != null) |
| { |
| HandleInsertUpdateException((source as RadGrid), e, false); |
| e.ExceptionHandled = true; |
| e.KeepInEditMode = true; |
| } |
| } |
where HandleInsertUpdateException is my function for printing the error message.
The problem I'm faced with is this: whenever the user hits the Cancel link, the updated (incorrect) value still gets displayed in the grid.
What is the proper way to refresh the grid to have it display the original value whenever Update fails?
This is the definition we have in .aspx
<telerik:RadCalendar ID="RadCalendar2" runat="server" Font-Names="Arial,Verdana,Tahoma"
ForeColor="Black" Skin="Outlook" Style="border-color: #ececec"
EnableViewSelector="True" AutoPostBack="false">
</telerik:RadCalendar>
A function with the following lines is called on pageload:
RadCalendar2.SpecialDays.Clear();
RadCalendar2.SelectedDates.Clear();
RadCalendarDay NewDay = new RadCalendarDay(RadCalendar2);
foreach (DataRow drrow in dtALLDates.Rows)
{
NewDay =
new RadCalendarDay(RadCalendar2);
NewDay.Date =
Convert.ToDateTime(drrow["CalendarDate"]);
NewDay.ToolTip =
Convert.ToInt32(drrow["SeatsAvailable"]) > 0 ? Convert.ToInt32(drrow["SeatsAvailable"]) > 1 ? drrow["SeatsAvailable"] + " seats are available" : "1 seat is available"
:
Convert.ToInt32(drrow["InSchedule"]) == 0 ? "Session not offered or it is a holiday." : "Seats are not available.";
Boolean bselect = Convert.ToInt32(drrow["SeatsAvailable"]) > 0 && Convert.ToBoolean(drrow["AllowEdit"]) == true ? true : false;
NewDay.IsSelectable = bselect;
if (Convert.ToBoolean(drrow["IsOpted"]) == true)
{
NewDay.IsSelected =
true;
RadCalendar2.SelectedDates.Add(
new RadDate(Convert.ToDateTime(drrow["CalendarDate"].ToString())));
}
RadCalendar2.SpecialDays.Add(NewDay);
}
When we navigate from one month to another month, the highlighted dates are cleared. I tried lot of things. But nothing working. Please help me to come out of this issue.
Thanks a lot in advance.
Siva
