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

the content of radeditor in radgrid template column is always empty

1 Answer 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mergen
Top achievements
Rank 1
Mergen asked on 09 Aug 2012, 02:26 AM
Hi ,

I'm new to telerik. I have a template column in my radgrid and I would like to add a radeditor to the edittemplate. The problem is when I click edit, and enter some new data to the radeditor, in the code behind, the content property of the radeditor is always getting blank string. Could someone give me some help with this issue? I have wasted lots of time on this. Below is the code:

<telerik:GridTemplateColumn HeaderText="Email Customizable Field 1" UniqueName="EmailBody1">
                    <EditItemTemplate>
                        <telerik:RadEditor ID="txtBody1Edit" runat="server" EditModes="Design" ToolbarMode="ShowOnFocus"
                            Width="315px" Height="65px" BorderStyle="None" EnableResize="False" Content='<% # bind ("EmailBody1") %>'>
                            <CssFiles>
                                <telerik:EditorCssFile Value="~/Styles/RichText.css" />
                            </CssFiles>
                            <Tools>
                                <telerik:EditorToolGroup Tag="Formatting">
                                    <telerik:EditorTool Name="Bold" />
                                    <telerik:EditorTool Name="Italic" />
                                    <telerik:EditorTool Name="Underline" />
                                    <telerik:EditorSeparator />
                                    <telerik:EditorSplitButton Name="ForeColor">
                                    </telerik:EditorSplitButton>
                                    <telerik:EditorSplitButton Name="BackColor">
                                    </telerik:EditorSplitButton>
                                    <telerik:EditorSeparator />
                                    <telerik:EditorDropDown Name="FontName">
                                    </telerik:EditorDropDown>
                                    <telerik:EditorDropDown Name="RealFontSize">
                                    </telerik:EditorDropDown>
                                </telerik:EditorToolGroup>
                            </Tools>
                            <ContextMenus>
                                <telerik:EditorContextMenu TagName="BODY">
                                    <telerik:EditorTool Name="Cut" />
                                    <telerik:EditorTool Name="Copy" />
                                    <telerik:EditorTool Name="Paste" />
                                    <telerik:EditorTool Name="SelectAll" />
                                </telerik:EditorContextMenu>
                            </ContextMenus>
                            
                            <TrackChangesSettings CanAcceptTrackChanges="False"></TrackChangesSettings>
                        </telerik:RadEditor>
                    </EditItemTemplate>

                    <ItemTemplate>
                        <asp:Label ID="lbBody1" runat="server" Text='<%# Eval("EmailBody1") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>


 Protected Sub RadGrid1_UpdateCommand(ByVal source As Object, ByVal e As GridCommandEventArgs)
         
        Dim editedItem As GridEditableItem = TryCast(e.Item, GridEditableItem)
        Dim EmailID As String = editedItem.OwnerTableView.DataKeyValues(editedItem.ItemIndex)("EmailID").ToString()
        Dim EmailTemplateName As String = (TryCast(editedItem("EmailTemplateName").Controls(0), TextBox)).Text
        Dim EmailSubject As String = TryCast(editedItem("EmailSubject").Controls(0), TextBox).Text
        Dim EmailBody1 As String = TryCast(e.Item.FindControl("txtBody1Edit"), RadEditor).Content.ToString
        Dim EmailBody2 As String = TryCast(e.Item.FindControl("txtBody2Edit"), RadEditor).Content.ToString
        Dim EmailBody3 As String = TryCast(e.Item.FindControl("txtBody3Edit"), RadEditor).Content.ToString
        Dim EmailBody4 As String = ""
        Dim Emailbody5 As String = ""

        Dim Footer As String = (TryCast(e.Item.FindControl("txtFooterEdit"), RadEditor)).Content.ToString

        Dim Attachment1 = (TryCast(e.Item.FindControl("fuAttachment1"), FileUpload)).FileName.ToString
        Dim Attachment2 = (TryCast(e.Item.FindControl("fuAttachment2"), FileUpload)).FileName.ToString
        Dim Attachment3 = (TryCast(e.Item.FindControl("fuAttachment3"), FileUpload)).FileName.ToString
        Dim Attachment4 = (TryCast(e.Item.FindControl("fuAttachment4"), FileUpload)).FileName.ToString
        Dim Attachment5 = (TryCast(e.Item.FindControl("fuAttachment5"), FileUpload)).FileName.ToString

        Dim EmailType As Integer = Integer.Parse((TryCast(e.Item.FindControl("dlEmailType"), DropDownList)).SelectedValue.ToString)

        Try
            QueryAdapters.SMS_DG_UpdateEmailTemplate(EmailID, EmailTemplateName, EmailSubject, EmailBody1, EmailBody2, EmailBody3, EmailBody4, Emailbody5, Footer, Attachment1, Attachment2, Attachment3, Attachment4, Attachment5, EmailType)
            Catch ex As Exception
                RadGrid1.Controls.Add(New LiteralControl("Unable to update the email template. Reason: " + ex.Message))
                e.Canceled = True
            End Try
    End Sub

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 13 Aug 2012, 02:30 PM
Hi,

I see that you are trying to find a control with ID "txtFooterEdit", but I don't see such control on the Page, are you sure that this is the correct ID? If there is no control with such on the Page, the FindControl method will return null in any case.

Check that and post your entire page source code along with the code behind if such control exists.

All the best,
Andrey
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.
Tags
Grid
Asked by
Mergen
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or