RadGrid control add, edit, refresh and delete. Works on a pa

Posted by Community Admin on 04-Aug-2018 12:36

RadGrid control add, edit, refresh and delete. Works on a page, but not on a backend page?

All Replies

Posted by Community Admin on 29-Sep-2011 00:00

Hi forum

I have created a RadGrid with automatically generated CRUD functions.

If i view a aspx file with the RadGrid in it works, however when i place it in a backend page onyl the delete and refresh works

It is the same code so can only assume something in the sitefinity backend is braking the functions

heres the 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>


Any help very much appreciated

Posted by Community Admin on 03-Oct-2011 00:00

Hello Bloommedia,

 I have replied to your support ticket on this issue, but I will copy the answer in the forum, as well - for the sake of our community:

Please check this thread for more information on how to do exactly what you need - it is an example for a custom module, but it shows the creation of a backend page, which gets data from a custom datatable:
 http://www.sitefinity.com/blogs/joshmorales/posts/11-05-26/creating_intra-site_modules_in_sitefinity_4.aspx

Regards,
Svetoslav Petsov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 07-Oct-2011 00:00

Hi

Sorry Iv watched the video and can not see where it describes a custom user control to edit a RadGrid

Maybe you can tell me at what point in the video this is dicussed?

Andrew

Bloom media

Posted by Community Admin on 11-Oct-2011 00:00

Hello Andrew,

 There is no RadGrid control used in the example I provided, but there is the most important part - which is getting the data from the data table that you created. After you get the data it is really easy to bind it to a Rad Grid control and enable its Automatic Delete/Update/Create which will allow you to control the data from your datatable from Sitefinity's backend pages.

Greetings,
Svetoslav Petsov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 11-Oct-2011 00:00

I don't have a problem connecting to the database, The problem I have is getting a user control to work as a custom editor for the RadGrid

Posted by Community Admin on 11-Oct-2011 00:00

Hi Andrew,

 Yeah, I forgot to mention about that issue - it turned out that it was a ViewState problem - just turn on the ViewState property of the page (from Title and Properties) and the problem must be gone (if not - try specifying that property of the Grid control as well).

Greetings,
Svetoslav Petsov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed