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