locked
display part of a text RRS feed

  • Question

  • User1172815769 posted

    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

    Thursday, December 1, 2011 1:42 AM

Answers

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 1, 2011 1:51 AM
  • User3866881 posted

    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);

    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!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 2, 2011 8:43 PM

All replies

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 1, 2011 1:51 AM
  • User3866881 posted

    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);

    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!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 2, 2011 8:43 PM
  • User-330204900 posted

    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?

    Saturday, December 3, 2011 8:13 AM