Hye all.
According my requirement to display the data from item template in gridview.
For example I input into a textbox:
This
sentence
contains
5
rows
After saving the data, I want to display it in my gridview and this is the code.
<asp:TemplateField HeaderText="Remarks">
<ItemTemplate>
<asp:Label ID="lblRemarks" runat="server" Text='<%# (Eval("COMMENT_T")).Replace("\n", "<br />") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
It nicely displayed in the gridview exactly like I input.
But when I want to edit the data, and display it back into the textbox, it didnt convert the "(br /)" statement into environment.newline.
This is how I did:
Dim row As GridViewRow = DirectCast(gdLotReg.Rows(e.CommandArgument), GridViewRow)
Dim lbl As Label = DirectCast(row.FindControl("lblRemarks"), Label)
Dim remarks As String = lbl.Text
Me.txtStatus.Text = remarks.Replace(Environment.NewLine, "<br />")
Is there anything wrong with my coding?