Click here to Skip to main content
12,758,605 members (31,112 online)
Rate this:
Please Sign up or sign in to vote.
See more: Gridview
Hye all.
According my requirement to display the data from item template in gridview.
For example I input into a textbox:

After saving the data, I want to display it in my gridview and this is the code.
<asp:TemplateField HeaderText="Remarks">
        <asp:Label ID="lblRemarks" runat="server" Text='<%# (Eval("COMMENT_T")).Replace("\n", "<br />") %>' ></asp:Label>

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?
Posted 11-Oct-12 21:38pm

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 12 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100