Limit the length of databound text on datalist

D

Derty

thanks for the reply John. To attempt to clarify, I need to limit the
length of characters that are displayed via text item on a datalist. In
the article link you supplied there's a reference to the following code
that would, I presume, 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.

Thanks.
 
R

Rad [Visual C# MVP]

Hey Derty,

You can limit that from the database level like so:

select substring(Columname,1,10) + '...' from tablename

This will return data in this form, limited to 10 characters

data111111....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,573
Members
45,046
Latest member
Gavizuho

Latest Threads

Top