
<telerik:RadScheduler ID="RadScheduler1" ColumnWidth="2000px" RowHeaderWidth="2000px" DayView-GroupingDirection="Vertical" RowHeaderHeight="500px" runat="server" DataSourceID="SqlDataSource2" DataEndField="ENDDATE" DataKeyField="ID" Skin="Telerik" DataSubjectField="SUBJECTS" DataStartField="STARTDATE" AllowDelete="False" AllowEdit="False" AllowInsert="False" DayEndTime="20:00:00" OverflowBehavior="Expand" SelectedView="MonthView" OnDataBound="RadScheduler1_DataBound" OnAppointmentCreated="RadScheduler1_AppointmentCreated" CssClass="ConfigurationPanel1" OnTimeSlotCreated="RadScheduler1_TimeSlotCreated" OnAppointmentDataBound="RadScheduler1_AppointmentDataBound" GroupingDirection="Vertical" EnableViewState="False" DisplayDeleteConfirmation="False" EnableAdvancedForm="False" EnableResourceEditing="False" ReadOnly="True" MinutesPerRow="60" OnAppointmentCommand="RadScheduler1_AppointmentCommand"> <TimelineView GroupBy="SESS" GroupingDirection="Vertical" /> <ResourceTypes> <telerik:ResourceType KeyField="SESS" Name="SESS" TextField="SESS" ForeignKeyField="SESS" DataSourceID="SqlDataSource2" /> </ResourceTypes> <DayView GroupingDirection="Vertical" /></telerik:RadScheduler><asp:SqlDataSource ID="SqlDataSource2" EnableCaching="true" runat="server" ConnectionString="Data Source=(local);Initial Catalog=oDirectv3;Persist Security Info=True;User ID=o;Password=abacus" SelectCommand="sp_Timetable_View" DeleteCommand="sp_Timetable_View" ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>" DeleteCommandType="StoredProcedure" SelectCommandType="StoredProcedure" OnSelecting="SqlDataSource2_Selecting"> <SelectParameters> <asp:SessionParameter DefaultValue="" Name="selectionType" SessionField="viewOptions" Type="String" /> <asp:SessionParameter DefaultValue="" Name="selectedItems" SessionField="selectedItems" Type="String" /> <asp:SessionParameter DefaultValue="" Name="selectedTerms" SessionField="selectedTerms" Type="String" /> <asp:Parameter Name="RangeStart" /> <asp:Parameter Name="RangeEnd" /> </SelectParameters> <DeleteParameters> <asp:Parameter Name="selectionType" Type="String" /> <asp:Parameter Name="selectedItems" Type="String" /> <asp:Parameter Name="selectedTerms" Type="String" /> </DeleteParameters>protected void Page_Load(object sender, EventArgs e){ if (!Page.IsPostBack) { BLL.BLL obj = new BLL.BLL(); try { int Day = obj.Get_Max_Day_Viewer(Convert.ToString(Session["ActiveDatabase"])); //RadScheduler1.WeekView. = Day; RadScheduler1.TimelineView.NumberOfSlots = Day; //it makes sure that the Viewer is showing the date of the timetable RadScheduler1.SelectedDate = obj.Get_Selected_Date_Viewer(Convert.ToString(Session["ActiveDatabase"])); } catch (SqlException ex) { lblMessage.Visible = true; lblMessage.Text = ex.Message; } finally { obj = null; } } }OnDeleteCommand
="Grid_DeleteCommand"
protected
void Grid_DeleteCommand(object source, GridCommandEventArgs e)
{
GridDataItem dataItem = (GridDataItem)e.Item;
string name= dataItem["Name"].Text;
try
{
var Id= (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"];
DeleteItem(Id);
InsertGridMessage("Name: " + name+ " is deleted!", false);
}
catch (Exception ex)
{
InsertGridMessage(
"Name: " + name+ " cannot be deleted. Reason: " + ex.Message, true);
e.Canceled =
true;
}
}
private
void InsertGridMessage(string message, bool isFailure)
{
var lblMessage = new Label
{
ID =
"LblGridMessage",
Text = message,
ForeColor = isFailure?
Color.Red:Color.Green
};
Grid.Controls.AddAt(0, lblMessage);
}
When i delete the item for first time it all works fine. But any action on radgrid will throw following exception. The reason is because the viewstate is not updated. Any ideas?Webpage error details
Message: Sys.WebForms.PageRequestManagerServerErrorException: Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
Line: 6
Char: 84093
Code: 0
URI: https://localhost/EzURWeb/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3a8f393b2b-3315-402f-b504-cd6d2db001f6%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%3aen-US%3acf630f82-0e77-4618-bf5c-22b81f4ec1c5%3a16e4e7cd%3af7645509%3a22a6274a%3a24ee1bba%3ae330518b%3a1e771326%3ac8618e41%3aed16cbdc%3a86526ba7%3a8e6f0d33%3aaa288e2d%3aa7e79140%3a6a6d718d%3a874f8ea2%3a19620875%3a33108d14%3a8674cba1%3ab7778d6c%3ac08e9f8a%3aa51ee93e%3a59462f1
| <telerik:AjaxSetting AjaxControlID="gvSearchResults"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="gvSearchResults" /> |
| <telerik:AjaxUpdatedControl ControlID="modalComment" /> |
| <telerik:AjaxUpdatedControl ControlID="rptComments" /> |
| <telerik:AjaxUpdatedControl ControlID="modalStatus" /> |
| <telerik:AjaxUpdatedControl ControlID="rptStatus" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| <telerik:GridTemplateColumn UniqueName="Title" HeaderText="Title" InitializeTemplatesFirst="false" SortExpression="Title"> |
| <ItemTemplate> |
| <table cellspacing="0" width="100%"> |
| <tr> |
| <%#Eval("Title") %> <asp:ImageButton ID="imgButton" runat="server" ImageUrl="~/images/icons/16/message_add.png" OnClick="fillModalComment" /> |
| </tr> |
| </table> |
| </ItemTemplate> |
| <ItemStyle HorizontalAlign="Left" /> |
| </telerik:GridTemplateColumn> |
| public void fillModalComment(object sender, EventArgs e) |
| { |
| int reqID = 0; |
| reqID = int.Parse(((ImageButton)sender).CommandArgument); |
| rptComments.DataSource = Comments.GetComments(reqID); |
| rptComments.DataBind(); |
| MainSearch ms = new MainSearch(reqID); |
| string title = "Comments on " + ms.Title; |
| int len = ms.Title.Length; |
| if (title.Length < 40) |
| modalComment.Title = title; |
| else |
| modalComment.Title = title.Substring(0, 40) + "..."; |
| modalComment.Show(); |
| } |