Preserving Carriage Returns and Line Feeds

I’m working on a company knowledge base where we use one form for input and another to search for and retrieve relevant documents based on topic, subtopic, and keywords. I use a simple BAQ to locate the correct information and then display it. My issue is that when I convert the data to a string to populate a text field, it removes all line breaks and runs all the text together. I know that’s not how it’s saved because if I go back into my entry and pull the same record up, the line breaks are there. They simply disappear when I am trying to send them to another text field. Is there a way within a customization to pull the information and then populate a text field without losing the line breaks?

Input screen:

search form:

this is the relevant code that I am using:

		DynamicQueryAdapter dqadptr = new DynamicQueryAdapter(oTrans);
	    string baqname = "tedKnowledgeBase";
	    Ice.BO.QueryExecutionDataSet dsBAQ = dqadptr.GetQueryExecutionParametersByID(baqname);		
	    dsBAQ.ExecutionParameter[0].ParameterID = "Title";
	    dsBAQ.ExecutionParameter[0].IsEmpty = false;
	    dsBAQ.ExecutionParameter[0].ParameterValue = chosenArticle;
	    dqadptr.ExecuteByID(baqname, dsBAQ);
	    DataTable results = dqadptr.QueryResults.Tables[0];
	    if (results != null && results.Rows.Count > 0)			
			var workingRow = results.Rows[0];
			txtTitle.Text = workingRow["UD20_ShortChar04"].ToString();
			txtTopic.Text = workingRow["UD20_ShortChar01"].ToString();
			txtSubTopic.Text = workingRow["UD20_ShortChar02"].ToString();
			txtAuthor.Text = workingRow["UD20_ShortChar03"].ToString();
			dteEntryDate.Value = workingRow["UD20_Date01"];
			txtKeyWords.Text = workingRow["UD20_Character01"].ToString();		
			txtNotes.Text = workingRow["UD20_Character02"].ToString();

	    results = null;

The issue is on the txtNotes.Text = workingRow[“UD20_Character02”].ToString();
Is there a way to do this that will retain my carriage returns and line feeds?

Try one of these two lines. They both refer to the different new line characters. I believe one is Char(10) and one is Char(13). Either way, we want to replace the new line characters with the epicor-friendly newline.

string myCom = MyComment.Text.Replace("\x0A",Environment.NewLine);
// - or -
string myCom = MyComment.Text.Replace("\x0D",Environment.NewLine);

I hope this helps!

1 Like

Thank you so much Nate. It was the second one that fixed it for me.

1 Like