Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
XML
<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:

VB
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?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900