This is a migrated thread and some comments may be shown as answers.

What type of SQL field do I use for RadEditor

9 Answers 215 Views
Editor
This is a migrated thread and some comments may be shown as answers.
AkAlan
Top achievements
Rank 2
AkAlan asked on 26 Mar 2010, 07:57 PM
I have a sql varchar(max) field I'm using now to store instructions for an Inspection record. I want to use the RadEditor to edit the instructions but I haven't seen where it shows the kind of SQL field to bind to. Would I want to change it to a binary field?

9 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 30 Mar 2010, 03:16 PM
Hi AkAlan,

RadEditor is not a databound control and you can think of it as an enhanced <asp:TextBox> control. You can see how to load / save content in a DB in this demo: Save In Database.

You should use nvarchar instead of varchar, because very often the users insert Unicode symbols in the content area of RadEditor. You can review the following blog post for more information: NVARCHAR versus VARCHAR.

Sincerely yours,
Rumen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
AkAlan
Top achievements
Rank 2
answered on 30 Mar 2010, 06:14 PM
Rumen, Thanks for the reply, but I do wish your examples were a little more "begginer" friendly. Not much in the way of code explanations, Telerik just leaves it to me to reverse engineer what is going on. As for nvarchar, I do not expect any other language than english since I am creating a web app just for use within my company. Is there any other reason to use nvarchar other than foreign languages? Thanks again for the reply.
0
Rumen
Telerik team
answered on 31 Mar 2010, 03:05 PM
Hi,

In case that you will save content without Unicode symbols then there are not problems to use varchar SQL data field.


Greetings,
Rumen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
AkAlan
Top achievements
Rank 2
answered on 31 Mar 2010, 04:21 PM
I got it to work easily with a sqlDataAdapter. I will post what I used for others. Thanks for your help with the understanding.

Just to get started I added a RadEditor, sqlDatasource and a button to my page. The button simply ran the update command of the sqldatasource. 
<telerik:RadEditor ID="RadEditorTest" ContentFilters="DefaultFilters,PdfExportFilter" 
 Width="700px" runat="server" height="900px" SkinID="DefaultSetOfTools" ExportSettings-OpenInNewWindow="true"  Skin="WebBlue">  
                        <ExportSettings OpenInNewWindow="True">  
                        </ExportSettings> 
                        <Modules> 
                            <telerik:EditorModule Name="RadEditorStatistics" Visible="false" Enabled="true" /> 
                            <telerik:EditorModule Name="RadEditorDomInspector" Visible="false" Enabled="true" /> 
                            <telerik:EditorModule Name="RadEditorNodeInspector" Visible="false" Enabled="true" /> 
                            <telerik:EditorModule Name="RadEditorHtmlInspector" Visible="false" Enabled="true" /> 
                        </Modules> 
                        <Content> 
                        </Content> 
   </telerik:RadEditor> 
     
  <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" Text="Update RadEditor Content"/> 
Just to be complete, here is my sqldatasource.
<asp:SqlDataSource ID="sdsTaskInstructions" runat="server"   
        ConnectionString="<%$ ConnectionStrings:AAIOMSConnectionString %>"   
         UpdateCommand="spUpdateFAC_TaskInstructions"   
        UpdateCommandType="StoredProcedure"   
        SelectCommand="spSelectFAC_TaskInstructions"   
        SelectCommandType="StoredProcedure">  
        <SelectParameters> 
            <asp:SessionParameter DefaultValue="1136" Name="TaskID" SessionField="TaskID"   
                Type="Int32" /> 
        </SelectParameters> 
        <UpdateParameters> 
            <asp:Parameter Name="TaskID" Type="Int32" /> 
            <asp:Parameter Name="Instructions" Type="String" /> 
        </UpdateParameters> 
    </asp:SqlDataSource> 


 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click  
        sdsTaskInstructions.Update()  
    End Sub  
 
Protected Sub sdsTaskInstructions_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles sdsTaskInstructions.Updating  
 
        Dim instructionText As String = Me.RadEditorTest.Content  
        e.Command.Parameters("@TaskID").Value = "1136" 
        e.Command.Parameters("@Instructions").Value = instructionText 
    End Sub 
I also had a formview on the page to display the results once I clicked the update button.
Anyway it works well and I can't wait to deploy it, my customers are going to love it.

0
Terri-Lynn
Top achievements
Rank 1
answered on 03 Jun 2011, 07:02 PM
Thanks so much AkAlan for posting your solution.  I have a basic question to go along with this.  Since the RadEditor isn't a databound control, how did you intially SET your instructions in the RadEditor?  
0
AkAlan
Top achievements
Rank 2
answered on 03 Jun 2011, 07:12 PM
I put a Formview and a SqlDataSource on the page. Here is the whole page. Also have a selectedindexchanged  event handler

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="RadEditor.aspx.vb" Inherits="Test_RadEditor"%>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    
      
  
    <telerik:RadComboBox ID="rcRwps" DataSourceID="sdsRwps" AutoPostBack = "true" EnableTextSelection="true" Width ="500px" DataTextField="TaskDescription" 
                                        DataValueField="TaskID" runat="server">
    </telerik:RadComboBox>
        <telerik:RadButton ID="rbPrint" Text="Print" runat="server">
    </telerik:RadButton>
          
       <asp:FormView ID="FormView1" runat="server" AllowPaging="True" 
        DataSourceID="sdsTaskInstructions" DataKeyNames="TaskID" 
        EnableModelValidation="True">
   <EditItemTemplate>
       
      
       <telerik:RadEditor ID="RadEditor1" runat="server"  Skin="Vista" Width="900px" Height="900px"
           Content='<%# Bind("InstructionTextHtml") %>'>
           <Tools>
               <telerik:EditorToolGroup>
                   <telerik:EditorTool Name="Cut" />
                   <telerik:EditorTool Name="Copy" />
                   <telerik:EditorTool Name="Paste" />
                   <telerik:EditorTool Name="AjaxSpellCheck" />
                   <telerik:EditorTool Name="FindAndReplace" />
                   <telerik:EditorTool Name="Undo" />
                   <telerik:EditorTool Name="Redo" />
                   <telerik:EditorTool Name="PasteFromWord" />
                   <telerik:EditorTool Name="FontSize" />
                   <telerik:EditorTool Name="Underline" />
                   <telerik:EditorTool Name="StrikeThrough" />
                   <telerik:EditorTool Name="Bold" />
                   <telerik:EditorTool Name="ForeColor" />
                   <telerik:EditorTool Name="FontName" />
                   <telerik:EditorTool Name="Print" />
                   <telerik:EditorTool Name="ConvertToLower" />
                   <telerik:EditorTool Name="ConvertToUpper" />
                   <telerik:EditorTool Name="InsertTable" />
                   <telerik:EditorTool Name="InsertOrderedList" />
                     
                      
                     
                    
               </telerik:EditorToolGroup>
           </Tools>
           <Modules>
               <telerik:EditorModule Name="RadEditorStatistics" />
           </Modules>
       </telerik:RadEditor>
       <br />
       <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
           Text="Update">
       </asp:LinkButton>
       <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
           Text="Cancel">
       </asp:LinkButton>
   </EditItemTemplate>
  
   <ItemTemplate>
        
       RadTextBox:
       <br />
       <telerik:RadEditor ID="re1" runat="server" Skin="Vista" EditModes="Preview"  Width="900px" Height="900px"
           Content='<%# Bind("InstructionTextHtml") %>'>
           <Tools>
               <telerik:EditorToolGroup>
               </telerik:EditorToolGroup>
           </Tools>
          <Modules>
               <telerik:EditorModule Name="RadEditorStatistics" />
           </Modules>
       </telerik:RadEditor>
       <br />
        
       <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
           Text="Edit">
       </asp:LinkButton>
       <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
           Text="Delete">
       </asp:LinkButton>
       <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
           Text="New">
       </asp:LinkButton>
   </ItemTemplate>
       
</asp:FormView
  
     
   <%-- <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateEditColumn="True" 
        DataSourceID="sdsTaskInstructions" GridLines="None">
    <MasterTableView DataSourceID="sdsTaskInstructions">
      
  
            <RowIndicatorColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
  
            <ExpandCollapseColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
    </MasterTableView>
    </telerik:RadGrid>--%>
      
    <asp:SqlDataSource ID="sdsTaskInstructions" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AAIOMSConnectionString %>" 
         UpdateCommand="spUpdateFAC_TaskInstructions" 
        UpdateCommandType="StoredProcedure" 
        SelectCommand="spSelectFAC_TaskInstructions" 
        SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:SessionParameter DefaultValue="1665" Name="TaskID" SessionField="TaskID" 
                Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="TaskID" Type="Int32" />
            <asp:Parameter Name="InstructionTextHtml" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
      
     <asp:SqlDataSource ID="sdsRwps" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AAIOMSConnectionString %>" 
        SelectCommand="spSelectFAC_Rwps" 
        SelectCommandType="StoredProcedure">
     </asp:SqlDataSource>
    </form>
</body>
</html>


Protected Sub rcRwps_SelectedIndexChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles rcRwps.SelectedIndexChanged
      Session("TaskID") = rcRwps.SelectedValue
      Me.FormView1.DataBind()
  End Sub
0
Terri-Lynn
Top achievements
Rank 1
answered on 03 Jun 2011, 08:21 PM
Perfect!  That works!!  :)
0
Terri-Lynn
Top achievements
Rank 1
answered on 03 Jun 2011, 10:12 PM
Would you also be able to share your complete code behind file?  I'm having issues with the intellisense not picking up my RadEditor object?  
0
AkAlan
Top achievements
Rank 2
answered on 03 Jun 2011, 10:25 PM

Here are the only Imports that I use in the code behind.
Imports

 

 

Telerik.Web.UI

 

Imports

 

 

System.Configuration

 

Imports

 

 

System.Data

 

Tags
Editor
Asked by
AkAlan
Top achievements
Rank 2
Answers by
Rumen
Telerik team
AkAlan
Top achievements
Rank 2
Terri-Lynn
Top achievements
Rank 1
Share this question
or