Click here to Skip to main content
11,704,315 members (61,887 online)
Rate this: bad
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 20:38pm

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 740
1 OriginalGriff 520
2 Maciej Los 355
3 Andy Lanng 284
4 CPallini 275
0 OriginalGriff 8,824
1 Sergey Alexandrovich Kryukov 8,247
2 CPallini 5,197
3 Maciej Los 4,726
4 Mika Wendelius 3,606

Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 12 Oct 2012
Copyright © CodeProject, 1999-2015
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