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

RadEditor Colum updating in Server side Codebehind

4 Answers 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RJ
Top achievements
Rank 1
RJ asked on 07 Oct 2013, 01:15 PM
Hi All,

I have found online sample of updating data of Radeditor column but the updating code is on aspx side (http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx).. Is there a sample code to update it on code behind? I cant seem to get the value of the Radeditor Column on Grid_Update command. Thanks in advance..

4 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 07 Oct 2013, 01:33 PM
Hi,

Please try the following code snippet to access the RadEditor in code behind.

ASPX:
<telerik:GridHTMLEditorColumn UniqueName="HTMLEditorColumn" HeaderText="HTMLEditorColumn"                        DataField="Contents">
</telerik:GridHTMLEditorColumn>

C#:
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
   {
       if (e.Item is GridEditableItem)
       {
           GridEditableItem edit = (GridEditableItem)e.Item;
           RadEditor editor = (RadEditor)edit["HTMLEditorColumn"].Controls[0]; //Access the RadEditor
           string content=editor.Text; //Get the contents inside the editor
       }
   }

Thanks,
Princy
0
RJ
Top achievements
Rank 1
answered on 08 Oct 2013, 06:45 AM
Hi Princy, Im having a weird error

ArgumentOutOfRangeException was unhandled by user code
Specified argument was out of the range of valid values. Parameter name: index..

when implementing this code.

<telerik:GridHTMLEditorColumn DataField="Question" HeaderText="Question" UniqueName="MyQuestion" Resizable="False" >
<HeaderStyle Width="220px" HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />
</telerik:GridHTMLEditorColumn>
 
If TypeOf e.Item Is Telerik.Web.UI.GridEditableItem Then
            Dim edit As Telerik.Web.UI.GridEditableItem = DirectCast(e.Item, Telerik.Web.UI.GridEditableItem)
            Dim editor As RadEditor = DirectCast(edit("MyQuestion").Controls(0), RadEditor)
            Dim stringcontent As String = editor.Text
End If


Im wondering if its the problem on my page coz its a user control and using masterpage.
0
RJ
Top achievements
Rank 1
answered on 08 Oct 2013, 09:15 AM
Hi Princy, Im having a weird error

ArgumentOutOfRangeException was unhandled by user code
Specified argument was out of the range of valid values. Parameter name: index..

when implementing this code.

<telerik:GridHTMLEditorColumn DataField="Question" HeaderText="Question" UniqueName="MyQuestion" Resizable="False" >
<HeaderStyle Width="220px" HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />
</telerik:GridHTMLEditorColumn>
 
If TypeOf e.Item Is Telerik.Web.UI.GridEditableItem Then
            Dim edit As Telerik.Web.UI.GridEditableItem = DirectCast(e.Item, Telerik.Web.UI.GridEditableItem)
            Dim editor As RadEditor = DirectCast(edit("MyQuestion").Controls(0), RadEditor)
            Dim stringcontent As String = editor.Text
End If


Im wondering if its the problem on my page coz its a user control and using masterpage.
0
RJ
Top achievements
Rank 1
answered on 08 Oct 2013, 09:16 AM
Was able to make it work.. Seems like there has been a problem on the class that loads the usercontrol.. Thanks again Princy!
Tags
Grid
Asked by
RJ
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
RJ
Top achievements
Rank 1
Share this question
or