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

[Solved] RadEditor in RadGrid doesn't persist his value

2 Answers 178 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sébastien
Top achievements
Rank 2
Sébastien asked on 15 Oct 2009, 02:26 PM
Telerik Team,

I'm trying to change the editor control for a specific field ("Description" field), from a textBox to a RadEditor (because I want a multiline edit for this value).
Everything works just fine if I use a GridBoundColumn, but when I try to use a GridHTMLEditorColumn (as described in some demo), the value of the editor is not well transmitted to the objects accessible in UpdateCommand (as well as in InsertCommand which is handled by the same function).

Maybe I'm doing something wrong ? Maybe I'm too "in the code" to see what's really on it ? Could you please review my uses of the Telerik objects and give me a potential solution ?

<%@ Control Language="vb" Inherits="Scam.AnnuairePro.Edit" AutoEventWireup="false" 
    Explicit="True" CodeBehind="EditAnnuairePro.ascx.vb" %> 
<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %> 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
    <script type="text/javascript"
            function RowDblClick(sender, eventArgs) 
            { 
              sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical()); 
            } 
    </script> 
</telerik:RadCodeBlock> 
 
 <style type="text/css"
    .GridEditRow_Default  
    { 
        background:#cccccc !important; 
    } 
    .GridEditRow_Default a  
    { 
        color:#333333; 
        } 
    </style> 
 
<asp:Label runat="server" ID="lblMessage"></asp:Label> 
<telerik:RadGrid ID="RadGrid1" GridLines="None" ShowStatusBar="True" PageSize="15" 
    AllowPaging="True" AllowSorting="False" runat="server" ShowGroupPanel="True"  EnableViewState="True"
    <mastertableview autogeneratecolumns="false" commanditemdisplay="TopAndBottom" enablenorecordstemplate="true" 
        allowautomaticinserts="true" editmode="editForms" allowautomaticupdates="true" 
        datakeynames="ItemId" onupdatecommand="RadGrid1_UpdateCommand" onneeddatasource="RadGrid1_NeedDataSource" 
        showstatusbar="true" oninsertcommand="RadGrid1_UpdateCommand" ondeletecommand="RadGrid1_DeleteCommand"
        <GroupByExpressions> 
                    <telerik:GridGroupByExpression> 
                        <SelectFields> 
                            <telerik:GridGroupByField FieldAlias="Categorie" FieldName="CategoryID"></telerik:GridGroupByField> 
                        </SelectFields> 
                        <GroupByFields> 
                            <telerik:GridGroupByField FieldName="CategoryID" SortOrder="Ascending"></telerik:GridGroupByField> 
                        </GroupByFields> 
                    </telerik:GridGroupByExpression> 
                </GroupByExpressions> 
            <Columns> 
            <telerik:GridButtonColumn CommandName="MoveUp" Text="Move Up" UniqueName="MoveUp" ButtonType="ImageButton"
                    </telerik:GridButtonColumn> 
                         <telerik:GridButtonColumn CommandName="MoveDown" Text="Move Down" UniqueName="MoveDown" ButtonType="ImageButton"
                    </telerik:GridButtonColumn> 
            <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete" /> 
            <telerik:GridEditCommandColumn UpdateText="Update" UniqueName="EditCommandColumn" 
                        CancelText="Cancel" EditText="Edit"></telerik:GridEditCommandColumn> 
                <telerik:GridBoundColumn DataField="Titre" HeaderText="Titre" UniqueName="Titre" 
                    SortExpression="Titre"
                </telerik:GridBoundColumn> 
                <telerik:GridHTMLEditorColumn  DataField="Description" HeaderText="Description" UniqueName="Description" 
                    SortExpression="Description"
                </telerik:GridHTMLEditorColumn > 
                <telerik:GridBoundColumn DataField="Adresse" HeaderText="Adresse" UniqueName="Adresse" 
                    SortExpression="Adresse"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Telephone" HeaderText="Telephone" UniqueName="Telephone" 
                    SortExpression="Telephone"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="URL" HeaderText="URL" UniqueName="URL" 
                    SortExpression="URL"></telerik:GridBoundColumn> 
                     
                <telerik:GridBoundColumn DataField="Courriel" HeaderText="Courriel" UniqueName="Courriel" 
                    SortExpression="Courriel"></telerik:GridBoundColumn> 
                    
                      <telerik:GridBoundColumn DataField="CategoryID"  
                      HeaderText="Categorie" UniqueName="CategoryID" 
                    SortExpression="CategoryID"
                    </telerik:GridBoundColumn> 
                     
                    <telerik:GridDropDownColumn UniqueName="CategoriesList" 
                        SortExpression="SortOrderInfoID" 
                        HeaderText="Categorie" ListTextField="Titre" 
                        ListValueField="CategoryID"  
                        DataField="CategoryID"  
                        visible="false"
                        </telerik:GridDropDownColumn> 
                         
                <telerik:GridBoundColumn DataField="LastModificationDate" HeaderText="Date de derni&egrave;re modification" UniqueName="LastModificationDate" 
                    SortExpression="LastModificationDate"></telerik:GridBoundColumn> 
                     
                <telerik:GridBoundColumn DataField="LastModificationUserID" HeaderText="par" UniqueName="LastModificationUserID" 
                    SortExpression="LastModificationUserID"></telerik:GridBoundColumn> 
                         
                         
            </Columns> 
            <EditFormSettings CaptionFormatString="Edition des d&eacute;tails de l'entr&eacute;e nommée {0}" CaptionDataField="Titre"
                    <FormTableItemStyle Width="100%" Height="29px"></FormTableItemStyle> 
                    <FormTableStyle GridLines="None" CellSpacing="0" CellPadding="2"></FormTableStyle> 
                    <FormStyle Width="100%" BackColor="#eef2ea"></FormStyle> 
                    <EditColumn ButtonType="ImageButton" /> 
                </EditFormSettings> 
              
                 <NoRecordsTemplate></NoRecordsTemplate
        </mastertableview> 
    <clientsettings> 
                <ClientEvents OnRowDblClick="RowDblClick" /> 
                <Resizing 
                    AllowColumnResize="True" 
                    AllowRowResize = "false" 
                    ResizeGridOnColumnResize = "false" 
                    ClipCellContentOnResize = "true" 
                    EnableRealTimeResize = "true" /> 
            </clientsettings> 
    <pagerstyle mode="NextPrevAndNumeric" /> 
</telerik:RadGrid> 
<p> 
    <asp:LinkButton CssClass="CommandButton" ID="cmdCancel" resourcekey="cmdReturn" runat="server" 
        BorderStyle="none" Text="Retour" CausesValidation="False"></asp:LinkButton> 
</p> 
 


' 
' DotNetNuke® - http://www.dotnetnuke.com 
' 
 
Imports DotNetNuke 
Imports DotNetNuke.Common 
Imports DotNetNuke.Services.Exceptions 
Imports DotNetNuke.Services.Localization 
Imports DotNetNuke.Entities.Users 
 
Imports Telerik.Web.UI 
Imports Telerik.Web.UI.Editor 
Imports System.Drawing 
 
 
 
Namespace MyCompany.MyClass 
 
    ''' ----------------------------------------------------------------------------- 
    ''' <summary> 
    ''' The EditMyClass class is used to manage content 
    ''' </summary> 
    ''' <remarks> 
    ''' </remarks> 
    ''' <history> 
    ''' </history> 
    ''' ----------------------------------------------------------------------------- 
    Partial Class Edit 
        Inherits Entities.Modules.PortalModuleBase 
#Region "Private Members" 
 
        Private ItemId As Integer = Null.NullInteger ' -1 
#End Region 
#Region "Event Handlers" 
 
        ''' ----------------------------------------------------------------------------- 
        ''' <summary> 
        ''' Page_Load runs when the control is loaded 
        ''' </summary> 
        ''' <remarks> 
        ''' </remarks> 
        ''' <history> 
        ''' </history> 
        ''' ----------------------------------------------------------------------------- 
        Private Sub Page_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load, Me.Load 
            Try 
 
 
                ' Generates false entries 
                'Dim objA As New MyClassInfo 
                'Static RandomNumGen As New System.Random 
                'objA.Titre = "Test " & RandomNumGen.Next 
                'objA.Description = "Desc " & RandomNumGen.Next 
                'APCtl.AddEntry(objA) 
 
 
 
                Me.RadGrid1.DataSource = Me.EmployeesData 
                If Not Me.Page.IsPostBack Then 
                    ' Define current texts 
                    Me.RadGrid1.MasterTableView.NoRecordsTemplate = New NoRecordsTemplate("lblNoEntry.Text"Me.LocalResourceFile) 
                End If 
 
 
            Catch exc As Exception    'Module failed to load 
                ProcessModuleLoadException(Me, exc) 
            End Try 
        End Sub 
 
        Private Sub RadGrid1_UpdateCommand(ByVal source As System.ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand, RadGrid1.InsertCommand 
 
            Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem) 
            Dim editMan As GridEditManager = editedItem.EditManager 
 
            Dim ID As String = Null.NullInteger  
            If Not e.Item.ItemIndex = Null.NullInteger Then 
                ID = (CType(e.Item, GridEditFormItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ItemId").ToString 
            End If 
 
            Dim column As GridColumn 
            Dim objAP As New MyClassInfo 
 
            For Each column In e.Item.OwnerTableView.Columns 
                If TypeOf column Is IGridEditableColumn Then 
                    Dim editableCol As IGridEditableColumn = CType(column, IGridEditableColumn) 
                    If (editableCol.IsEditable) Then 
                        Dim editor As IGridColumnEditor = editMan.GetColumnEditor(editableCol) 
 
                        Dim editorType As String = CType(editor, Object).ToString() 
                        Dim editorText As String = "unknown" 
                        Dim editorValue As Object = Nothing 
 
                        If (TypeOf editor Is GridHTMLEditorColumnEditor) Then   ' The RadEditor 
                            editorText = CType(editor, GridHTMLEditorColumnEditor).Editor.Text 
                            editorValue = CType(editor, GridHTMLEditorColumnEditor).Editor.Text 
                        End If 
 
                        If (TypeOf editor Is GridTextColumnEditor) Then 
                            editorText = CType(editor, GridTextColumnEditor).Text 
                            editorValue = CType(editor, GridTextColumnEditor).Text 
                        End If 
 
                        If (TypeOf editor Is GridBoolColumnEditor) Then 
                            editorText = CType(editor, GridBoolColumnEditor).Value.ToString() 
                            editorValue = CType(editor, GridBoolColumnEditor).Value 
                        End If 
 
                        If (TypeOf editor Is GridDropDownColumnEditor) Then 
                            editorText = CType(editor, GridDropDownColumnEditor).SelectedText & "; " & CType(editor, GridDropDownColumnEditor).SelectedValue 
                            editorValue = CType(editor, GridDropDownColumnEditor).SelectedValue 
                        End If 
 
                        Try 
 
                            If Not ID = "-1" Then 
                                Dim changedRows As DataRow() = Me.EmployeesData.Tables("Employees").Select("ItemId = " & editedItem.OwnerTableView.DataKeyValues(editedItem.ItemIndex)("ItemId")) 
                                ' Chaque DropDownList effectuant des transformations devra avoir sa transformation 
                                If column.UniqueName = "CategoriesList" Then 
                                    changedRows(0)("CategoryID") = editorValue 
                                Else 
                                    changedRows(0)(column.UniqueName) = editorValue 
                                End If 
 
                                Me.EmployeesData.Tables("Employees").AcceptChanges() 
 
                            End If 
 
                            Select Case column.UniqueName 
                                Case "ItemId" 
                                    objAP.ItemId = CType(editorValue, Integer
                                Case "Titre" 
                                    objAP.Titre = editorValue 
                                Case "Description"  ' The RadEditor 
                                    objAP.Description = editorValue 
                                Case "Adresse" 
                                    objAP.Adresse = editorValue 
                                Case "Telephone" 
                                    objAP.Telephone = editorValue 
                                Case "URL" 
                                    objAP.URL = editorValue 
                                Case "Courriel" 
                                    objAP.Courriel = editorValue 
                                Case "CategoriesList" 'Equivalent unique de CategoryID, soit la liste deroulante 
                                    objAP.CategoryID = CType(editorValue, Integer
 
                            End Select 
 
                        Catch ex As Exception 
                            SetMessage("<strong>Unable to set value of column '" & column.UniqueName & "'</strong> - " + ex.Message) 
                            e.Canceled = True 
                        End Try 
 
 
 
                    End If 
                End If 
            Next 
            If Not e.Canceled = True Then 
                Dim objAPCtl As New MyClassController 
 
                ' TimeStamp actualisation 
                objAP.LastModificationDate = Date.Now 
                objAP.LastModificationUserID = Me.UserId 
 
                If ID = Null.NullInteger.ToString Then 
                    ' New entry 
                    objAPCtl.AddEntry(objAP) 
                    SetMessage("Entree ajoutee"
 
                    Dim MyEmployeesData As DataSet = New DataSet 
 
                    Dim APCtl As New MyClassController 
                    Dim objAPs As New List(Of MyClassInfo) 
                    objAPs = APCtl.GetEntries() 
                    Dim objC As New CollectionToDataSet(objAPs) 
 
                    ' I convert the collection to Dataset in order to remain comparable with Telerik samples as found in your intranet 
                    MyEmployeesData = objC.CreateDataSet 
 
                    ' Define PK on Dataset for .Find() method 
                    Dim pk(1) As DataColumn 
                    pk(0) = MyEmployeesData.Tables(0).Columns("ItemId"
                    MyEmployeesData.Tables(0).PrimaryKey() = pk 
 
                    Me.EmployeesData = MyEmployeesData 
 
                    ' GiveDataSource() 
                    ' Rebind and close edit window 
                    ' TODO : Find a way to rebind and close the edit window 
                    ' TODO Note : (Seb) The methods given by Telerik on forums and samples doesn't works here (Version 2008..1314 problem ?) 
                    Response.Redirect(NavigateURL(Request.QueryString("ctl"), "mid=" & Request.QueryString("mid"))) 
 
                Else 
                    ' Update 
                    Dim objAPorigin As New MyClassInfo 
                    objAPorigin = objAPCtl.GetEntryByID(ID) 
 
                    ' Here is a list of the columns not displayed in the Grid 
                    objAP.ItemId = objAPorigin.ItemId 
                    objAP.SortOrderInfoID = objAPorigin.SortOrderInfoID 
 
                    ' Update LastSortOrder when category changes 
                    Dim booClearCache As Boolean = False 
                    If objAP.CategoryID <> objAPorigin.CategoryID Then 
                        objAPCtl.UpdateSortOrder(objAP.SortOrderInfoID, objAPCtl.GetLastSortOrder(Constantes.ItemType.Entree, objAP.CategoryID).SortOrder + 1, objAP.CategoryID) 
                        ' booClearCache = True 
                    End If 
 
                    objAPCtl.UpdateEntry(objAP) 
 
                    Me.RadGrid1.MasterTableView.ClearEditItems() 
 
                    ' If booClearCache Then 
                    ' Enforce update on the grid 
                    ' Refresh cat group if needed 
                    ' Refresh timeStamp 
                    Me.Session.Remove("EmployeesData"
                    Me.RadGrid1.DataSource = Me.EmployeesData 
                    Me.RadGrid1.DataBind() 
                    'End If 
 
                    SetMessage("Entry updated"
 
                End If 
            End If 
        End Sub 
 
        Private Sub RadGrid1_ItemDataBound(ByVal sender As ObjectByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound 
            If (TypeOf e.Item Is GridEditableItem AndAlso CType(e.Item, GridEditableItem).IsInEditMode) Then 
                Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem) 
                Dim editMan As GridEditManager = editedItem.EditManager 
 
                Dim editor As GridDropDownColumnEditor = CType(editMan.GetColumnEditor("CategoriesList"), GridDropDownColumnEditor) 
 
                Dim htmleditor As GridHTMLEditorColumnEditor = CType(editMan.GetColumnEditor("Description"), GridHTMLEditorColumnEditor) 
                Dim objRadE As RadEditor = CType(htmleditor.ContainerControl.Controls(0), RadEditor) 
 
                objRadE.CssClass = "MyRadEditor" 
                objRadE.AutoResizeHeight = True 
 
                ' TODO 
                'objRadE.EditModes = EditModes.All 
                objRadE.EnableResize = False 
                objRadE.ToolbarMode = EditorToolbarMode.ShowOnFocus 
                objRadE.Tools.Clear() 
                Dim main As New EditorToolGroup() 
                objRadE.Tools.Add(main) 
                Dim bold As New EditorTool() 
                bold.Name = "Bold" 
                bold.ShortCut = "CTRL+B" 
                main.Tools.Add(bold) 
                Dim italic As New EditorTool() 
                italic.Name = "Italic" 
                italic.ShortCut = "CTRL+I" 
                main.Tools.Add(italic) 
                Dim underline As New EditorTool() 
                underline.Name = "Underline" 
                underline.ShortCut = "CTRL+U" 
                main.Tools.Add(underline) 
 
 
 
                Dim ID As String = "-1" 
 
                If Not e.Item.ItemIndex = -1 Then 
                    ID = (CType(e.Item, GridEditFormItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ItemId").ToString 
                End If 
 
                ' Hides some columns 
                editedItem("CategoryID").Parent.Visible = False 
                editedItem("LastModificationDate").Parent.Visible = False 
                editedItem("LastModificationUserID").Parent.Visible = False 
 
                ' Modify the list control as per custom conventions 
                Dim objAPCtl As New MyClassController 
                Dim objCats As New List(Of CategoryInfo) 
 
                Dim objEmptyCat As New CategoryInfo 
                objEmptyCat.CategoryID = 0 
                objEmptyCat.SortOrderInfoId = -1 
                objEmptyCat.Titre = "--   Choose   --" 
                objCats.Add(objEmptyCat) 
 
                objCats.AddRange(objAPCtl.GetCategories()) 
 
                editor.DataTextField = "Titre" 
                editor.DataValueField = "CategoryID" 
                editor.DataSource = objCats 
                Editor.DataBind() 
 
                If Not ID = -1 Then 
                    Dim objPA As New MyClassInfo 
                    objPA = objAPCtl.GetEntryByID(ID) 
                    'If Not editedItem("CategoryID") Is Nothing Then 
                    ' TODO : (seb) We should be able to get the CategoryId from the context RadGrid but I don't know how asap. 
                    editor.SelectedValue = objPA.CategoryID.ToString 
                    'CType(editedItem("CategoryID").Controls(0), TextBox).Text 
                    'End If 
                End If 
 
                'And so on 
            ElseIf (TypeOf e.Item Is GridDataItem AndAlso Not e.Item.IsInEditMode) Then 
                Dim item As GridDataItem = e.Item 
 
                ' Replaces some values of the grid so the user has a better comprehension of the stored data 
                Dim ObjAPCtl As New MyClassController 
 
                Dim catID As String = item("CategoryID").Text 
                If catID = "-1" Or catID = "0" Or catID = Null.NullString Then 
                    ' No category 
                    item("CategoryID").Text = "-" 
                Else 
                    ' Category given 
 
                    Dim ObjCat As New CategoryInfo 
                    ObjCat = ObjAPCtl.GetCategoryByID(CType(catID, Integer)) 
                    item("CategoryID").Text = ObjCat.Titre 
 
                End If 
 
                ' Crop the Description which could be very long 
                If item("Description").Text.Length >= 100 Then 
                    item("Description").Text = item("Description").Text.Substring(0, 100) & "[...]" 
                End If 
 
                ' Replace the UserID by the display name 
                Dim objUCtl As New UserController 
                item("LastModificationUserID").Text = objUCtl.GetUser(Me.PortalId, CType(item("LastModificationUserID").Text, Integer)).DisplayName 
 
                ' The date 
                'item("LastModificationDate").Text = CType(item("LastModificationDate").Text, Date).ToLongDateString & " " & CType(item("LastModificationDate").Text, Date).ToLongTimeString 
 
                ' The sortOrder 
                CType(item("MoveUp").Controls(0), ImageButton).ImageUrl = ResolveUrl("~/images/action_up.gif"
                CType(item("MoveDown").Controls(0), ImageButton).ImageUrl = ResolveUrl("~/images/action_down.gif"
 
                Dim ID As String = "-1" 
 
                If Not e.Item.ItemIndex = -1 Then 
                    ID = (CType(e.Item, GridDataItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ItemId").ToString 
                End If 
 
                ' TODO : Update Telerik.Web.UI and use Drag'n'Drop for Re-ordering 
 
                Dim LastSortIndex As Integer = ObjAPCtl.GetLastSortOrder(Constantes.ItemType.Entree, catID).SortOrder 
                Dim MySortIndex As Integer = ObjAPCtl.GetSortOrderByID(ObjAPCtl.GetEntryByID(ID).SortOrderInfoID).SortOrder 
 
                If MySortIndex = LastSortIndex And MySortIndex = 1 Then 
                    ' 1 entry only 
                    item("MoveUp").Controls(0).Visible = False 
                    item("MoveDown").Controls(0).Visible = False 
                ElseIf MySortIndex = LastSortIndex Then 
                    ' End of the list 
                    item("MoveDown").Controls(0).Visible = False 
                ElseIf MySortIndex = 1 Then 
                    ' Start of the list 
                    item("MoveUp").Controls(0).Visible = False 
                End If 
 
 
 
            End If 
        End Sub 
 
 
        Private Sub RadGrid1_ItemCommand(ByVal source As System.ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand 
            If e.Item.GetType.Equals(GetType(GridDataItem)) Then 
 
 
                ' TODO : Update Telerik.Web.UI and use Drag'n'Drop for Re-ordering 
 
 
                ' Up/Down for re-ordering 
                Dim item As GridDataItem = CType(e.Item, GridDataItem) 
 
                Dim ID As String = "-1" 
                If Not e.Item.ItemIndex = -1 Then 
                    ID = item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ItemId").ToString 
                End If 
 
                Dim objAPCtl As New MyClassController 
                Dim objAP As MyClassInfo = objAPCtl.GetEntryByID(ID) 
 
                If e.CommandName = "MoveUp" Then 
                    objAPCtl.UpdateSortOrderByMove(objAP.SortOrderInfoID, Constantes.ItemType.Entree, objAP.CategoryID, True
                ElseIf e.CommandName = "MoveDown" Then 
                    objAPCtl.UpdateSortOrderByMove(objAP.SortOrderInfoID, Constantes.ItemType.Entree, objAP.CategoryID, False
                End If 
 
                Me.Session.Remove("EmployeesData"
                Me.RadGrid1.DataSource = Me.EmployeesData 
                Me.RadGrid1.DataBind() 
            End If 
        End Sub 
 
 
 
        Private Sub GiveDataSource() 
            RadGrid1.DataSource = Me.EmployeesData 
            Me.EmployeesData.Tables("Employees").PrimaryKey = New DataColumn() {Me.EmployeesData.Tables("Employees").Columns("ItemId")} 
        End Sub 
 
        Private Sub RadGrid1_NeedDataSource(ByVal source As System.ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource 
            If Not Me.EmployeesData Is Nothing Then 
                GiveDataSource() 
            Else 
                Me.RadGrid1.DataSource = New List(Of MyClassInfo) 
            End If 
        End Sub 
 
        Private Sub Page_PreRender(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.PreRender 
            If Not MyBase.IsPostBack Then 
                ' Me.RadGrid1.MasterTableView.Items(0).Edit = True 
                Me.RadGrid1.MasterTableView.Rebind() 
            End If 
        End Sub 
 
        Protected Sub RadGrid1_DeleteCommand(ByVal source As ObjectByVal e As GridCommandEventArgs) Handles RadGrid1.DeleteCommand 
            Dim ID As String = (CType(e.Item, GridDataItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ItemId").ToString 
 
            Dim MyEmployeesData As DataSet = New DataSet 
            MyEmployeesData = Me.EmployeesData 
 
            Dim employeeTable As DataTable = MyEmployeesData.Tables("Employees"
            If Not (employeeTable.Rows.Find(ID) Is NothingThen 
                employeeTable.Rows.Find(ID).Delete() 
                employeeTable.AcceptChanges() 
            End If 
 
            Me.EmployeesData = MyEmployeesData 
 
            GiveDataSource() 
 
            Dim APCtl As New MyClassController 
            APCtl.DeleteEntryById(ID) 
 
            SetMessage("Entree " & ID & " deleted"
 
 
        End Sub 
 
        Protected Sub SetMessage(ByVal message As String
            RadGrid1.Controls.Add(New LiteralControl(message)) 
        End Sub 
 
        Public Property EmployeesData() As DataSet 
            Get 
                Dim obj As Object = Me.Session("EmployeesData"
                If Not obj Is Nothing Then 
                    Return CType(obj, DataSet) 
                End If 
 
                Dim MyEmployeesData As DataSet = New DataSet 
 
                Dim APCtl As New MyClassController 
                Dim objAPs As New List(Of MyClassInfo) 
                objAPs = APCtl.GetEntries() 
 
                ' No entries ? 
                If objAPs.Count > 0 Then 
 
                    Dim objC As New CollectionToDataSet(objAPs) 
 
                    ' I convert the collection to Dataset in order to remain comparable with Telerik samples as found in your intranet 
                    MyEmployeesData = objC.CreateDataSet 
 
                    ' Define PK on Dataset for .Find() method 
                    Dim pk(1) As DataColumn 
                    pk(0) = MyEmployeesData.Tables(0).Columns("ItemId"
                    MyEmployeesData.Tables(0).PrimaryKey() = pk 
 
                    Me.Session("EmployeesData") = MyEmployeesData 
 
                    Return MyEmployeesData 
                Else 
                    ' No entries . 
                    Return Nothing 
                End If 
 
            End Get 
            Set(ByVal value As DataSet) 
                Me.Session("EmployeesData") = value 
            End Set 
        End Property 
 
 
 
        ''' ----------------------------------------------------------------------------- 
        ''' <summary> 
        ''' cmdCancel_Click runs when the cancel button is clicked 
        ''' </summary> 
        ''' <remarks> 
        ''' </remarks> 
        ''' <history> 
        ''' </history> 
        ''' ----------------------------------------------------------------------------- 
        Private Sub cmdCancel_Click(ByVal sender As ObjectByVal e As EventArgs) Handles cmdCancel.Click 
            Try 
                Response.Redirect(NavigateURL(), True
            Catch exc As Exception    'Module failed to load 
                ProcessModuleLoadException(Me, exc) 
            End Try 
        End Sub 
#End Region 
 
    End Class 
 
End Namespace 




2 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 20 Oct 2009, 04:37 PM
Hello Fichot,

Does referencing the Content property of the RadEditor embedded in GridHTMLEditorColumn instead of its Text property on update command produces different result? Namely:

If (TypeOf editor Is GridHTMLEditorColumnEditor) Then   ' The RadEditor  
                        editorText = CType(editor, GridHTMLEditorColumnEditor).Editor.Content
                        editorValue = CType(editor, GridHTMLEditorColumnEditor).Editor.Content
                    End If  

You may use the kb article below for further reference:
http://www.telerik.com/support/kb/aspnet-ajax/grid/using-radeditor-as-editor-in-template-column-of-radgrid.aspx

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sébastien
Top achievements
Rank 2
answered on 21 Oct 2009, 08:26 AM
Hi Sebastian, and thank you for your answer.
Yes it does change something, it works. I was sure that I tried this before without success.

Cheers,

S.F.
Tags
Grid
Asked by
Sébastien
Top achievements
Rank 2
Answers by
Sebastian
Telerik team
Sébastien
Top achievements
Rank 2
Share this question
or