2011-09-29 49 views
1

我在一個sitefinity頁面上有一個RadGrid,我正在使用它創建一個模塊來在後端的數據庫表上創建CRUD模型。Sitefinity RadGrid無法在後端頁面工作

如果我把RadGrid放在一個aspx頁面並在瀏覽器中查看,它工作正常,但是當我將它添加到一個站點有限後端頁面時,只有刷新和刪除工作,添加和更新不會保存到數據庫。

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="newsArticleAdmin.ascx.cs" Inherits="SitefinityWebApp.Modules.newsArticles.admin.newsArticleAdmin" %> 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> 

<div style="clear:both;"></div> 
<div id="adminContents"> 

<h2>News Articles</h2> 
<p>These articles appear on the home page</p> 
<br /> 


<telerik:RadScriptManager ID="RadScriptManager1" Runat="server"> 
</telerik:RadScriptManager> 


<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> 
    <AjaxSettings> 
     <telerik:AjaxSetting AjaxControlID="RadGrid1"> 
      <UpdatedControls> 
       <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 

       <telerik:AjaxUpdatedControl ControlID="SqlDataSource1" /> 

      </UpdatedControls> 
     </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:RadAjaxManager> 


    <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" 
     AllowAutomaticInserts="True" AllowAutomaticUpdates="True" 
     AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" CellSpacing="0" 
     DataSourceID="SqlDataSource1" GridLines="None" Skin="Telerik"> 


<MasterTableView AutoGenerateColumns="False" CommandItemDisplay="TopAndBottom" 
      DataKeyNames="fld_blogPostId" DataSourceID="SqlDataSource1" 
      EditMode="InPlace"> 
<CommandItemSettings ExportToPdfText="Export to PDF" 
     AddNewRecordText="Add new article"></CommandItemSettings> 

<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"> 
</RowIndicatorColumn> 

<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"> 
</ExpandCollapseColumn> 

    <Columns> 
     <telerik:GridBoundColumn DataField="fld_blogPostId" DataType="System.Int32" 
      FilterControlAltText="Filter fld_blogPostId column" HeaderText="fld_blogPostId" 
      ReadOnly="True" SortExpression="fld_blogPostId" UniqueName="fld_blogPostId"> 
     </telerik:GridBoundColumn> 
     <telerik:GridBoundColumn DataField="fld_blogTitle" 
      FilterControlAltText="Filter fld_blogTitle column" HeaderText="fld_blogTitle" 
      SortExpression="fld_blogTitle" UniqueName="fld_blogTitle"> 
     </telerik:GridBoundColumn> 
     <telerik:GridBoundColumn DataField="fld_blogContents" 
      FilterControlAltText="Filter fld_blogContents column" 
      HeaderText="fld_blogContents" SortExpression="fld_blogContents" 
      UniqueName="fld_blogContents"> 
     </telerik:GridBoundColumn> 
     <telerik:GridBoundColumn DataField="fld_blogDate" 
      FilterControlAltText="Filter fld_blogDate column" HeaderText="fld_blogDate" 
      SortExpression="fld_blogDate" UniqueName="fld_blogDate"> 
     </telerik:GridBoundColumn> 
     <telerik:GridBoundColumn DataField="fld_blogImage" 
      FilterControlAltText="Filter fld_blogImage column" HeaderText="fld_blogImage" 
      SortExpression="fld_blogImage" UniqueName="fld_blogImage"> 
     </telerik:GridBoundColumn> 
    </Columns> 

<EditFormSettings> 
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn> 
</EditFormSettings> 
</MasterTableView> 

     <StatusBarSettings LoadingText="Loading articles..." 
      ReadyText="Articles ready" /> 

<FilterMenu EnableImageSprites="False"></FilterMenu> 

<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu> 
    </telerik:RadGrid> 


    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
     ConnectionString="<%$ ConnectionStrings:NewsArticlesConnectionString %>" 
     DeleteCommand="DELETE FROM [tbl_newsArticles] WHERE [fld_blogPostId] = @fld_blogPostId" 
     InsertCommand="INSERT INTO [tbl_newsArticles] ([fld_blogTitle], [fld_blogContents], [fld_blogDate], 
[fld_blogImage]) VALUES(@fld_blogTitle, @fld_blogContents, @fld_blogDate, @fld_blogImage)" 
     SelectCommand="SELECT * FROM tbl_newsArticles" 
     UpdateCommand="UPDATE [tbl_newsArticles] SET [fld_blogTitle] = @fld_blogTitle, [fld_blogContents] = @fld_blogContents, 
[fld_blogDate] = @fld_blogDate, [fld_blogImage] = @fld_blogImage WHERE fld_blogPostId = @fld_blogPostId"> 
     <DeleteParameters> 
      <asp:Parameter Name="fld_blogPostId" /> 
     </DeleteParameters> 
     <InsertParameters> 
      <asp:Parameter Name="fld_blogTitle" /> 
      <asp:Parameter Name="fld_blogContents" /> 
      <asp:Parameter Name="fld_blogDate" /> 
      <asp:Parameter Name="fld_blogImage" /> 
     </InsertParameters> 
     <UpdateParameters> 
      <asp:Parameter Name="fld_blogTitle" /> 
      <asp:Parameter Name="fld_blogContents" /> 
      <asp:Parameter Name="fld_blogDate" /> 
      <asp:Parameter Name="fld_blogImage" /> 
      <asp:Parameter Name="fld_blogPostId" /> 
     </UpdateParameters> 
    </asp:SqlDataSource> 


</div> 

沒有人見過這個,知道一個修復:

如果與阿賈克斯radgrid控件

這裏相互矛盾的是我的代碼,我只能假設在sitefinity後端的東西嗎?

乾杯

安德魯 @ atmd83

回答

3

嘗試在後臺頁面編輯器中打開頁面,並確保「啓用視圖狀態」設置爲true。默認情況下,Sitefinity中的後端頁面通常會設置爲禁用,因爲大多數後端使用AJAX。

希望這對您有所幫助!

+0

奇妙的,像夢一樣工作,我正在檢查源代碼並看到視圖狀態,但我想那是控件的視圖狀態而不是母版頁。 – atmd