I have to separate by marks of \n
the content of a cell of GridView
to get different lines to appear in a cell.
The code in which I find myself is the following:
Modifying the DataTable
:
cmd = new OracleCommand();
cmd.Connection = cnn;
cmd.CommandText = comando;
da.SelectCommand = cmd;
da.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
string text = dt.Rows[i]["OBSFX"].ToString();
text = text.Replace("\n", " <br /> ");
dt.Rows[i]["OBSFX"] = text;
}
GridView1.DataSource = dt;
GridView1.DataBind();
Now modifying the GridView
directly:
cmd = new OracleCommand();
cmd.Connection = cnn;
cmd.CommandText = comando;
da.SelectCommand = cmd;
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
for (int i = 0; i < GridView1.Rows.Count; i++)
{
string text = GridView1.Rows[i].Cells[16].Text;
text = text.Replace("\n", "<br/>");
GridView1.Rows[i].Cells[16].Text = text;
}
GridView1.DataBind();
Neither way works. Any ideas?