I have a question about how to display a part of a text I mean if I have a long text I want to display part of it then if anyone go to read the full text it will click on a hyperlink called (Read more).. I retrieve text from several lines using sql statement
but I want to display the first or the two first lines in this text, How I do that???
I retrieve text from several lines using sql statement but I want to display the first or the two first lines in this text, How I do that??
Hello :)
According to what I know,I think you can convert the result to String, and then use SubString to fetch only part of the string and show onto the aspx page,Sample looks like this:
Your LINQ may look like this below:
var result = from e in XXX
select e.XXX.ToString().SubString(1,20);
Hi Ayah2011, is this in Dynamic Data? if so DD will always pull all the data form the DB for a column, if how ever you are talking about two columns one with short data and with the full the you would need a custom field template?
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Ayah2011
Member
142 Points
116 Posts
display part of a text
Dec 01, 2011 05:42 AM|LINK
Hello
I have a question about how to display a part of a text I mean if I have a long text I want to display part of it then if anyone go to read the full text it will click on a hyperlink called (Read more).. I retrieve text from several lines using sql statement but I want to display the first or the two first lines in this text, How I do that???
Thank you
setahamid
Participant
1299 Points
245 Posts
Re: display part of a text
Dec 01, 2011 05:51 AM|LINK
Check following link
http://stackoverflow.com/questions/6012942/how-to-limit-label-string-length-in-gridview-with-read-more-link
Hamid Seta
http://www.hamidseta.blogspot.com/
Remember to click “Mark as Answer” on the post, if it helps you.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: display part of a text
Dec 03, 2011 12:43 AM|LINK
Hello :)
According to what I know,I think you can convert the result to String, and then use SubString to fetch only part of the string and show onto the aspx page,Sample looks like this:
Your LINQ may look like this below:
var result = from e in XXX
select e.XXX.ToString().SubString(1,20);
Then in your aspx page:
<asp:HyperLink Id="hp" runat="server" NavigateUrl='<%#String.Format("Details.aspx?id={0}",id)%>' Text='<%#Eval("XXX")%>'/>
When coming to the Details.aspx with the query string "id", plz find the whole string out and show the complete one。
Best reguards!
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: display part of a text
Dec 03, 2011 12:13 PM|LINK
Hi Ayah2011, is this in Dynamic Data? if so DD will always pull all the data form the DB for a column, if how ever you are talking about two columns one with short data and with the full the you would need a custom field template?
Always seeking an elegant solution.