Save in Database

7 posts, 1 answers
  1. Adigard
    Adigard avatar
    61 posts
    Member since:
    Oct 2011

    Posted 03 Nov 2011 Link to this post

    Greetings,

    I have been trying to follow the steps of this demo to save the content of my Editor in my database.
    http://demos.telerik.com/aspnet-ajax/editor/examples/saveindatabase/defaultcs.aspx
    But it is not working unfortunately

    <form id="form1" runat="server">
    <div>
    <input type="hidden" name="EditedNews" runat="server" id="EditedNews" />
        <telerik:RadEditor ID="NewsEditor" runat="server">
        </telerik:RadEditor>
    </div>
    <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
    </telerik:RadScriptManager>
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
    <asp:SqlDataSource ID="SqlDataSourceRadEditor" runat="server"
        ConflictDetection="OverwriteChanges"
        ConnectionString="<%$ ConnectionStrings:IntranetConnectionString %>"
        DeleteCommand="DELETE FROM [rendezvous] WHERE [idRDV] = @idRDV"
        InsertCommand="INSERT INTO [rendezvous] ([rapport]) VALUES (@rapport) WHERE idRDV = @idRDV "
        SelectCommand="SELECT [idRDV], [rapport] FROM [rendezvous]"
        UpdateCommand="UPDATE [rendezvous] SET [rapport] = @rapport WHERE [idRDV] = @idRDV">
        <DeleteParameters>
            <asp:Parameter Name="idRDV" Type="Int32" />
            <asp:Parameter Name="rapport" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="rapport" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:QueryStringParameter Name="idRDV" QueryStringField="idRDV" Type="Int32" />
            <asp:Parameter Name="rapport" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
    </form>

    protected void Button1_Click(object sender, EventArgs e)
    {
        if (EditedNews.Value == string.Empty)
        {
           
            SqlDataSourceRadEditor.UpdateParameters.Add("NewsText", NewsEditor.Content);
            SqlDataSourceRadEditor.Update();
        }
     
         
    }


    PS: the RadEditor control is within a RadWindow and i pass an ID from a RadGrid to the window, that's why i have a
    <asp:QueryStringParameter Name="idRDV" QueryStringField="idRDV" Type="Int32" />

    To get back the ID.
    The Command i try to do is the update.

    Thanks in advance for your help
  2. Adigard
    Adigard avatar
    61 posts
    Member since:
    Oct 2011

    Posted 07 Nov 2011 Link to this post

    Nobody knows ?
  3. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5796 posts

    Posted 08 Nov 2011 Link to this post

    Hi Adigard,

    How you update the database is not related to the RadEditor. The reason why it is not working should be found in your database, as the RadEditor is very similar to a regular TextBox for this scenario - you obtain its content as an HTML string and what you do with it and how you store it in the database is up to the developer.


    Kind regards,
    Marin
    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
  4. Adigard
    Adigard avatar
    61 posts
    Member since:
    Oct 2011

    Posted 08 Nov 2011 Link to this post

    First of all , thank you for your help

    But i'm not sure to really understand where the problem comes from ...

    According to you , the problem might come from my table itself ?
    Nothing to add in the code i have posted above ?

    thank you in advance
  5. Answer
    Rumen
    Admin
    Rumen avatar
    14431 posts

    Posted 08 Nov 2011 Link to this post

    Hello Adigard,

    You can think of RadEditor as an advanced Asp:TextBox control. The only difference is that instead of using the Text property to get / set the content, you should use the Content property of RadEditor, which returns or set the HTML content. The Text property of RadEditor returns plain text only and is read only.

    If it will be easier for you, implement your scenario with a regular Asp:TextBox instead of using RadEditor. Once you are ready and if you face any problems replacing the textbox with radeditor, just send us a sample working project with the solution and we will do the replacement for you.

    Greetings,
    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
  6. Adigard
    Adigard avatar
    61 posts
    Member since:
    Oct 2011

    Posted 08 Nov 2011 Link to this post

    I managed to make it work perfectly!
    thank you!
  7. Adigard
    Adigard avatar
    61 posts
    Member since:
    Oct 2011

    Posted 08 Nov 2011 Link to this post

    ... resolved
Back to Top