I convert the input for the RadEditor (i.e., "\n" becomes "<br />") during the ItemDataBound() event for the RadGrid when loading the data. Then when I update the grid, I convert the RadEditor content back (i.e., "\n\r" becomes "\n") during the UpdateCommand() of the RadGrid. It took me a little bit of trial and error to discover exactly what text characters to replace, but these are working for my situation.
Here are my conversion functions:
private string _FormatRadEditorContentInput(string strText)
// Replace Line Feed with HTML line break.
string strResult = strText.Replace("\n", "<
private string _FormatRadEditorContentOutput(string strText)
// Replace Line Feed / Carriage Return with just a Line Feed.
string strResult = strText.Replace("\n\r ", "\n");
So during ItemDataBound() event, convert the data coming in as follows:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
if (e.Item is GridDataItem)
GridDataItem oItem = (GridDataItem)e.Item;
oItem["Comments"].Text = _FormatRadEditorContentInput(oItem["Comments"].Text);
During the UpdateCommand() event, convert the data as it is being saved as follows:
protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
GridEditableItem oEditedItem = e.Item as GridEditableItem;
string strComments = (oEditedItem.FindControl("radEditor_Comments") as RadEditor).Text;
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection sqlConnection = new SqlConnection(strConnString);
SqlCommand sqlCommand = new SqlCommand();
sqlCommand.CommandText = "UpdateTheTable";
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.Connection = sqlConnection;
I hope this helps you out.