Forum Moderators: open

Message Too Old, No Replies

Limit the length of databound text on datalist

         

dertyfern

7:12 pm on Dec 1, 2006 (gmt 0)

10+ Year Member



I'm using .net 2.0 with c# and I need to limit the length of characters that are displayed via text item on a datalist.

Here's sample code that would display the 'company name' contained in a table:

<td><%# DataBinder.Eval(Container.DataItem, "CompanyName") %></td>

My question is: how could you limit the number of characters displayed?

The reason for the question is the table field I'm using can be extremely lengthy in charaters and it doesn't make sense to display them all on a rendered page.

thx.

TheNige

8:10 pm on Dec 1, 2006 (gmt 0)

10+ Year Member



Use the SubString function to return the first n characters. Or you can use the Remove function on the string.