Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 04, 2012 01:37 AM by Decker Dong - MSFT
Dec 03, 2012 06:30 AM|LINK
Hello good sirs!
So, I've got a gridview which has an edit mode (in the normal mode, the containers are labels, and in edit mode textboxes). This is done by some TemplateFields, ItemTemplate, EditTemplate, etc. For example, (in my asp GridView):
<asp:Label ID="lcgCommentLabel" runat="server" Width="600px" Text='<%# Eval("Kommentar") %>'></asp:Label>
<asp:TextBox ID="lcgCommentTextBox" Width="594px" TextMode="MultiLine" runat="server" Text='<%# Eval("Kommentar")%>'></asp:TextBox>
And the information is saved to an SQL Database.
The problem is this: When a user is making a new line in edit mode (pushing enter), this is not to be seen in the label. In the label, all text are being wrapped together. If I turn the gridview into edit mode again, the textboxes still got the correct number
So, what I want here is therefore some sort of a "multiline" Label, so that the text in the Label appears in the same manner as in the TextBox.
(One soloution could be that the ItemTemplate also can be a TextBox, but that causes some other problems, like the height of that textbox should auto-grow, etc)
Hope I am somewhat clear.
Anyone got some ideas? Thanks in beforehand!
Dec 03, 2012 09:01 AM|LINK
You need to replace your line breaks (\r\n) with html breaks (<br/>). A line break works in a text box, but not in a label. If you want a break in a label you need an html break. I don't know how you do this with Eval, but try something like this;
<asp:Label ID="lcgCommentLabel" runat="server" Width="600px" Text='<%# Eval("Kommentar").ToString().Replace("\r\n", "<br/>") %>'></asp:Label>
Dec 03, 2012 09:13 AM|LINK
set fix width to lable and in edit mode set textbox property.....textmode="multiline"
Dec 04, 2012 01:37 AM|LINK
this is not to be seen in the label.
Do you mean your Label disappears in the edit mode of GridView?