Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Gridview with added Templates and TextBox does not display text

Posted on 2012-09-04
8
Medium Priority
?
706 Views
Last Modified: 2012-09-14
Hi,

I have a Gridview with added Templates, I have TextBoxs in the Templates.
(See code below)

The problem:
One of the textboxes display data in it as supposed to, but the second textbox only displays a one line in it.

What make it do that????

Thank you!!!

 <asp:TemplateField HeaderText="Comments" SortExpression="Comments">
                         <HeaderStyle ForeColor="White" Font-Names="Times New Roman" Font-Size="Small" />
                         <EditItemTemplate>
                             <asp:TextBox ID="txtcomments" runat="server" CssClass="LongUrlLabel " 
                                 Height="100px" ontextchanged="txtDescription_TextChanged" 
                                 Text='<%# Bind("Comments") %>' TextMode="MultiLine" Width="300px"></asp:TextBox>
                         </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label6" runat="server" Text='<%# Bind("Comments") %>' 
                                Width="150px" Height="16px" CssClass="LongUrlLabel"></asp:Label>
                        </ItemTemplate>
                         <ControlStyle Width="250px" />
                    </asp:TemplateField>

Open in new window

0
Comment
Question by:Rad1
  • 4
  • 4
8 Comments
 
LVL 26

Assisted Solution

by:Alan Warren
Alan Warren earned 2000 total points
ID: 38367362
Hi rad1,

CssClass="LongUrlLabel " should probably be CssClass="LongUrlLabel"
and one of the textboxes is TextMode="MultiLine" while the other is not.

Alan
0
 
LVL 26

Assisted Solution

by:Alan Warren
Alan Warren earned 2000 total points
ID: 38367367
Hang on... the other is a label!
Apologies...
Where's the other textbox?

Alan
0
 
LVL 26

Assisted Solution

by:Alan Warren
Alan Warren earned 2000 total points
ID: 38367395
There's a trick to that, instead of using a label in the itemtemplate, you use a textbox but format it as label, then you don't have to convert the linefeeds to html breaks '<br />'
I usually have a go at estimating the rows required, by counting the linefeeds SQL-Side, hard to get it exact though..

<asp:TextBox ID="NoteLabel" runat="server" BorderStyle="None" BorderWidth="0" 
                                  ReadOnly="true" Rows='<%# Eval("NOTE_ROWS") %>' Text='<%# Eval("Note") %>' 
                                  TextMode="MultiLine" Width="100%" />

Open in new window

SQL Bits:
,(isnull(dbo.Occurrs(REPLACE(Note,CHAR(10),'~~' ),'~~') + ((LEN([Note]) + 70)/70),1) / 2) + 2 as NOTE_ROWS

Open in new window

Occurs function:
ALTER FUNCTION [dbo].[Occurrs] ( @pInput VARCHAR(8000), @pSearchString VARCHAR(100) )
RETURNS INT AS  
BEGIN 
    RETURN (LEN(@pInput) - 
            LEN(REPLACE(@pInput, @pSearchString, ''))) /
            LEN(@pSearchString)
END

-- select dbo.Occurrs('LAN','A')   -- Returns 1

Open in new window


Alan
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Rad1
ID: 38367744
Thank you!!!

Both textboxes are textboxes
Both are in different itemtemplate
Both are multiline
0
 

Author Comment

by:Rad1
ID: 38370104
Its strange!!!

I have two pages with the same Gridview.  On the first one it works just fine (display data or text fully), but on the other page the Gridview textboxes do not work (only display a one line).
0
 
LVL 26

Accepted Solution

by:
Alan Warren earned 2000 total points
ID: 38374479
That is strange Rad1, are you sure they are identical?
Do they have the same style applied, css?

Alan
0
 

Author Comment

by:Rad1
ID: 38384032
Alan,

I found out that I was using
.LongUrlLabel  {  overflow:hidden;   } which was causing the rest of the text to display.
But, the second column was display the whole text correctly?????
0
 

Author Closing Comment

by:Rad1
ID: 38401147
Thank you Alan!!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question