Sitefinity RadGrid 无法在后端页面中工作
我在 sitefinity 页面上有一个 RadGrid,我使用它来创建一个模块来在后端的数据库表上进行 CRUD。
如果我将 RadGrid 放在 aspx 页面上并在浏览器中查看,它工作正常,但是当我将其添加到站点有限后端页面时,只有刷新和删除工作,添加和更新不会保存到数据库。
如果与 RadGrid Ajax 冲突,我只能假设 sitefinity 后端中的某些内容
是我的代码:
<%@ 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>
有人以前见过这个并知道修复吗?
干杯
安德鲁 @atmd83
I have a RadGrid on a sitefinity page, I am using it to create a module to proform CRUD on a database table in the backend.
If I put the RadGrid on a aspx page and view in browser, it works fine, However when I add it to a site finity back end page, Only the refresh and delete work, the add and update dont save to the database.
I can only assume something in the sitefinity backend if conflicting with the RadGrid Ajax
here is my code:
<%@ 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>
Anyone seen this before and know of a fix?
Cheers
Andrew
@atmd83
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在后端页面编辑器中打开页面,并确保“启用视图状态”设置为 true。默认情况下,Sitefinity 中的后端页面通常设置为禁用此功能,因为大多数后端都使用 AJAX。
希望这有帮助!
try opening the page in the backend page editor and make sure that "enable view state" is set to true. by default, backend pages in Sitefinity are usually set with this disabled, as most of the backend uses AJAX.
hope this is helpful!