Can't bind data from SQL to radEditor

2 posts, 1 answers
  1. Archna
    Archna avatar
    4 posts
    Member since:
    Apr 2013

    Posted 28 Apr 2013 Link to this post

    I am able to save data from the radEditor to my table in SQL but can't load data into the editor from the same table. What am I doing wrong?

    Here's my code:

    public

     

     

    static DataView GetSparcHelpContent(string pagePath)

     

    {

     

     

    Database db = DatabaseFactory.CreateDatabase();

     

     

     

    DataView dv = db.ExecuteDataSet("uspGetSparcHelpContent", pagePath).Tables[0].DefaultView;

     

     

     

    return dv;
    }

     

    <

     

     

    asp:ObjectDataSource ID="odsHelpContent" runat="server" TypeName="Wf.Sparc.DAL.DbAccess" SelectMethod="

     

    GetSparcHelpContent

     

    ">

    </

     

     

    asp:ObjectDataSource>

     

    <

     

     

    asp:LinkButton ID="PageIns" runat="server" Text="View / Edit Help" Font-Underline="true"

     

     

     

    toolTip="View more information related to this page" Visible="true" ></asp:LinkButton>

     

     

     

     

     

     

     

    <asp:Panel ID="ModalPanel" runat="server" style="display:none; width:480px; height:530px; background-color:White;

     

     

     

    border-width:2px; border-color:Black; border-style:solid; padding:20px;" DataSourceID="odsHelpContent" >

     

     

     

    <asp:Button ID="OKButton" runat="server" Text="Close" ForeColor="Black" /> <br /><br />

     

     

     

     

     

     

     

    <telerik:RadEditor ID="radBody" ToolbarMode="Default" ToolsFile="~/RadControls/ToolsFile.xml" runat="server"

     

     

     

    ContentFilters="RemoveScripts" EditModes="All" Height="450" SkinID="RadEditorSkin" Visible="true"

     

     

     

    Width="200" EnableResize="true" Content='<%# Bind("pageContent") %>'/>

     

     

     

     

     

     

     

    <script type="text/javascript">

     

     

     

     

     

     

     

    //This script must be below the RadEditor declaration

     

     

     

     

     

     

     

    //It displays the custom toolbar icon formatting FAQ

     

     

     

     

     

     

     

    //It replaces embedded scripts from a previous version of Telerik RadEditor

     

     

     

     

     

    Telerik.Web.UI.Editor.CommandList[

     

    "FormattingFAQ"] = function (commandName, editor, args) {

     

     

     

    var args = editor.get_html(true) //returns the HTML of the selection.

     

     

     

     

     

    editor.showExternalDialog(

     

     

    "/RadControls/FormattingFAQ.aspx",

     

    args,

    350,

    250,

     

     

    null,

     

     

     

    null,

     

     

     

    "Formatting FAQ",

     

     

     

    true,

     

    Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,

     

     

    true,

     

     

     

    true);

     

    };

     

     

    </script>

     

     

     

     

     

     

     

    <br /><br />

     

     

     

     

     

     

     

    <asp:Button ID="SaveButton" runat="server" Text="Save" ForeColor="Black" OnClientClick="needToConfirm = false;" OnClick="btnSave_Click" />

     

     

     

    <asp:Button ID="CancelButton" runat="server" Text="Cancel" ForeColor="Black" /> <br /><br /> <br /><br />

     

     

     

     

     

     

     

    </asp:Panel>

     

     

     

     

     

     

     

    <ajaxToolkit:ModalPopupExtender ID="mpePopup" runat="server" TargetControlId="PageIns" PopupControlID="ModalPanel"

     

     

     

    CancelControlID="CancelButton" OkControlID="OKButton" X="1050" Y="50" Drag="true" PopupDragHandleControlID="ModalPanel"/>

     

    protected

     

     

    void btnSave_Click(object sender, EventArgs e)

     

    {

     

     

    string pagePath = System.Web.HttpContext.Current.Request.Path.ToString();

     

    Wf.Sparc.DAL.

     

    DbAccess.UpdSparcHelpContent("ins", pagePath, radBody.Content, int.Parse(Session["userid"].ToString()));

     

    }

  2. Answer
    Rumen
    Admin
    Rumen avatar
    13884 posts

    Posted 29 Apr 2013 Link to this post

    Hello,

    Please, note that RadEditor is not databound control. You can think of RadEditor as an enhanced standard <asp:TextBox control and the way the editor has to be bound to a DataSource is similar to this of a standard <asp:TextBox>. You should use the Content property of RadEditor to set and obtain content in and from it.

    You can find more information how to populate RadEditor with data from a database in the following support resources:
    Save In Database demo,
    Save In A Database help article,
    RadGrid Edit Template,
    Edit Template In Grid help article, and
    Codeless Save In Database ASP.Net 2.0.


    If you experience any problems, please implement your scenario by replacing RadEditor with a standard Asp:TextBox control. You need to replace the Content property of RadEditor with the Text property of the TextBox control. Once you are able to load content in the TextBox replace it with RadEditor and change the Text property with Content.

    Best regards,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top