I have a SharePoint web part that I wrote in C # that is used to display SQL Server data based on user preferences. I retrieve the data using the DataReader, populate the DataSet and set this DataSet as a data source in the GridView and add this control to my page:
GridView outputGrid = new GridView();
outputGrid.CssClass = "OutputGrid";
outputGrid.DataSource = flipped_ds1;
outputGrid.RowDataBound += outputGrid_RowDataBound;
outputGrid.DataBind();
Controls.Add(outputGrid);
This gives me a simple HTML table with a declared CSS class and more. The only problem I encountered is that line breaks in data fields are not displayed at all. I just get a block of text that ignores the breaks that are present in the database when it is displayed in HTML. Coming through my code, I see that the lines of a new line are included in the text in the form "\ r \ n". I tried the regex:
Regex rgx = new Regex("\r\n");
string inputStr = Convert.ToString(dr[x]);
string outputStr = rgx.Replace(inputStr, "<br />");
newRow[ds3.Tables["Bobst Specs 3"].Columns[x]] = outputStr;
, "
" . HTML , "
":
<br />
SQL- - :
SELECT REPLACE (fldCustomerName, '. ', '.' + @NewLineChar)
, -, . , , , , , . , , , .