Click here to Skip to main content
Rate this: bad
good
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:
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?
Posted 11-Oct-12 20:38pm
snamyna1.2K

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

  Print Answers RSS
0 OriginalGriff 358
1 Sergey Alexandrovich Kryukov 234
2 PhilLenoir 179
3 MT_ 175
4 Yogesh Kumar Tyagi 165
0 Sergey Alexandrovich Kryukov 6,205
1 OriginalGriff 5,333
2 CPallini 2,473
3 Richard MacCutchan 1,617
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web04 | 2.8.140814.1 | Last Updated 12 Oct 2012
Copyright © CodeProject, 1999-2014
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