Datagrid shows summary - click for more info

The data displayed in one column of my datagrid (data from database) is a link. Rather than displaying all the info in that cell I want to only display say the first 100 characters with a ... at the end, so that if you want to read more you click on it. How might I go about doing this???

PS I already have the link working fine - I only need ideas about how to display only some of the data - Perhaps it's in the SQL?????

Thanks for any ideasI assume you are using a stored proc to bring the data back?

You can limit the characters you bring back from a particular field...I'll post the syntax in a minute.

It's something like....

select order_id
,order_name left(10) -- limits the field to first 10 chars
from order

============= EDIT ===================

this limits the [name] column to 10 chars...

select substring ([name],1,10)
fromcustomer

*'[name]' is the column, 1 is the starting character and 10 the end character.

Hope this helps.

AJNGreat thanks, could I than add a "....." at the end of the text that I choose to display?

Thanks loads
Much appreciatedNo probs.

Yep, you can do something like...

select substring ([name],1,10) 'Customer Name'
from customer

or

select substring ([name],1,10) as 'Customer Name'
from customer

AJNSorry, I misread that. Yes, I see what you mean now.

select substring ([name],1,10) + '...'
from customer

AJNThat's really great thanks loads, it seems quite simple now I was expecting something more complex!

Thanks
:DOoops I get an error:
A field or property with the name 'rfqQuestion' was not found on the selected datasource

I typed this in:
"SELECT rfqID, substring([rfqQuestion],1,20), rfqAnswer, rfqDateAdded,rfqStatus FROM faqlog WHERE rfqID= @ID"

???It does work in query analyser just not in my vb code...Sorry, try this...

"SELECT rfqID, substring([rfqQuestion],1,20) + '...' as 'rfqQuestion', rfqAnswer, rfqDateAdded,rfqStatus FROM faqlog WHERE rfqID= @ID"

Reason being, if you look in query analyser, when you use the substring command the column returned under substring has no name! So if you use:

substring([rfqQuestion],1,20) + '...' as 'rfqQuestion'

then you are manually naming the column.

Hope this helps.

AJNWorks perfectly thanks :)
 
Top