I'm trying to prevent page refreshes on a page with a single grid so I've tried to implement the Ajax Manager, the Ajax Panel and the Ajax Loading Panel. However, it is not working as I'd expect (or how the demo's work).
The code I have is as follows:
Code Behind:
Any ideas as to what I'm doing wrong?
The code I have is as follows:
<telerik:RadAjaxManager runat="server" ID="radAjaxManager" EnableAJAX="True"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="radInspection"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="radInspection" LoadingPanelID="radlpInspection"/> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel runat="server" ID="radlpInspection"></telerik:RadAjaxLoadingPanel> <telerik:RadAjaxPanel runat="server" ID="radpnlInspection" LoadingPanelID="radlpInspection" EnableAJAX="True"> <telerik:RadGrid runat="server" ID="radInspection" AllowPaging="True" AllowSorting="True" ShowHeader="True" GridLines="None" CellPadding="0" CellSpacing="0" PageSize="20" AllowFilteringByColumn="True" OnNeedDataSource="radInspection_OnNeedDataSource" OnItemCommand="radInspection_OnItemCommand"> <ClientSettings AllowColumnsReorder="False" EnableRowHoverStyle="True" EnablePostBackOnRowClick="True"> <Selecting AllowRowSelect="True"></Selecting> <Scrolling UseStaticHeaders="True"></Scrolling> </ClientSettings> <MasterTableView DataKeyNames="inspection_id" AutoGenerateColumns="False" AllowMultiColumnSorting="True" EnableHeaderContextMenu="True" AllowFilteringByColumn="True" CommandItemDisplay="TopAndBottom" Height="100%"> <NoRecordsTemplate>No inspections.</NoRecordsTemplate> <CommandItemSettings ShowAddNewRecordButton="False" ShowCancelChangesButton="False" ShowSaveChangesButton="False" ShowRefreshButton="True"></CommandItemSettings> <Columns> <telerik:GridBoundColumn DataField="inspection_id" HeaderText="ID" AllowFiltering="False"> <HeaderStyle Width="1%" VerticalAlign="Top" HorizontalAlign="Right"></HeaderStyle> <ItemStyle Width="1%" VerticalAlign="Top" HorizontalAlign="Right"></ItemStyle> </telerik:GridBoundColumn> <telerik:GridDateTimeColumn DataField="inspection_datetime" HeaderText="Inspection Date" EnableTimeIndependentFiltering="True" PickerType="DateTimePicker" DataFormatString="{0:MM/dd/yyyy HH:mm}" FilterControlWidth="85%"> <ItemStyle Width="5%" VerticalAlign="Top" HorizontalAlign="Left"></ItemStyle> <HeaderStyle Width="5%"></HeaderStyle> </telerik:GridDateTimeColumn> <telerik:GridBoundColumn DataField="inspector" HeaderText="Inspector" FilterControlWidth="75%"> <HeaderStyle Width="5%"></HeaderStyle> <ItemStyle Width="5%" VerticalAlign="Top" HorizontalAlign="Left"></ItemStyle> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="division" HeaderText="Division" FilterControlWidth="75%"> <HeaderStyle Width="5%"></HeaderStyle> <ItemStyle Width="5%" VerticalAlign="Top" HorizontalAlign="Left"></ItemStyle> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="full_grade" HeaderText="Grade" FilterControlWidth="75%"> <HeaderStyle Width="5%"></HeaderStyle> <ItemStyle Width="5%" VerticalAlign="Top" HorizontalAlign="Left"></ItemStyle> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="length_description" HeaderText="Length" FilterControlWidth="75%"> <HeaderStyle Width="5%"></HeaderStyle> <ItemStyle Width="5%" VerticalAlign="Top" HorizontalAlign="Left"></ItemStyle> </telerik:GridBoundColumn> <telerik:GridCheckBoxColumn DataField="complete" HeaderText="Completed" AllowFiltering="False"> <HeaderStyle Width="2%" HorizontalAlign="Right"></HeaderStyle> <ItemStyle Width="2%" VerticalAlign="Top" HorizontalAlign="Right"></ItemStyle> </telerik:GridCheckBoxColumn> </Columns> </MasterTableView> </telerik:RadGrid> </telerik:RadAjaxPanel>Code Behind:
protected void Page_Load(object sender, EventArgs e) { if (Session["Key"] != null) { Session["Key"] = -1; } if (!IsPostBack) { LoadData(); } } private void LoadData() { var inspections = dal.Inspection.GetVInspectionHeaders(); radInspection.DataSource = inspections; } protected void radInspection_OnNeedDataSource(object sender, GridNeedDataSourceEventArgs e) { LoadData(); } protected void radNew_OnClick(object sender, EventArgs e) { Session["Key"] = -1; Response.Redirect("header.aspx"); } protected void radInspection_OnItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == "RowClick") { GridEditableItem item = e.Item as GridEditableItem; if (item == null) { return; } var key = item.GetDataKeyValue("inspection_id").ToString(); Response.Redirect(string.Format("viewinspection.aspx?id={0}", key)); } } }Any ideas as to what I'm doing wrong?