locked
ListView text wrapping issues... RRS feed

  • Question

  • User-1164658185 posted

    Hey, all. I'm using a ListView . Very often, the text is too long to fit in the small boxes, and it has to wrap the text. This is fine.

    "United States" might turn into "United Sta...". All fine and good.

    How can I get the actual text it's displaying? If it's wrapping, I mean, how can I get back the string it's actually displaying (with ... and all)?

    Thanks.

    &nbsp;<%#DataBinder.Eval(Container,"DataItem.Country")%>,&nbsp;<%#DataBinder.Eval(Container,"DataItem.RegionName")%>,
                                    &nbsp;<%#DataBinder.Eval(Container,"DataItem.CityName")%>&nbsp;

     

    Friday, June 17, 2011 2:13 PM

Answers

  • User-1635004338 posted

    Hi,

    I think there are some cityname is shorter than 10 chars, so the error happens. You need to check it before:

    (Eval("CityName").ToString().Length > 10) ? (Eval("CityName").ToString().Substring(0, 10) + "...") : Eval("CityName")

    Thanks,

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 21, 2011 9:13 PM

All replies

  • User-168800120 posted
    <%#((string)DataBinder.Eval(Container,"DataItem.Country")).SubString(0,10)%>

    Hi

    I didn't get you totally.

    To wrap text you apply style="whitespace:normal;" to that control.

    If you wanna display upto some length of characters then You can use above code

     

     

    Friday, June 17, 2011 2:21 PM
  • User-1164658185 posted

    {"Index and length must refer to a location within the string.\r\nParameter name: length"}

     

     Not sure how to solve this one.

     

    Friday, June 17, 2011 2:53 PM
  • User-168800120 posted

    Hi Is text wrapping issue is fixed?

    And write in more detail i am not getting your problem .

     

     

     

    Please mark the replies as answers if they help you.

    Friday, June 17, 2011 3:05 PM
  • User-1164658185 posted

    From: FR, Poitou-Charentes,  Baignes-Sainte-Radegonde 

    http://www.omegalove.com/secure/searchresults.aspx?country=0&age1=18&age2=35&mygender=1&searchgender=2&withphoto=true&isonlinenow=true

    it wraps.

    see LABELLE

    Friday, June 17, 2011 6:22 PM
  • User-1635004338 posted

    Hi,

    Try this:

    Eval("Country").ToString().Substring(0, 10) + "..."

    For displaying all text, you may need another control to bind all the text from this Country field.

    Thanks,

    Tuesday, June 21, 2011 4:45 AM
  • User-1164658185 posted

    Index and length must refer to a location within the string.
    Parameter name: length

    &nbsp;<%#DataBinder.Eval(Container, "DataItem.CityName").ToString().Substring(0, 10) + "..." %>


     

    Tuesday, June 21, 2011 12:42 PM
  • User-1635004338 posted

    Hi,

    I think there are some cityname is shorter than 10 chars, so the error happens. You need to check it before:

    (Eval("CityName").ToString().Length > 10) ? (Eval("CityName").ToString().Substring(0, 10) + "...") : Eval("CityName")

    Thanks,

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 21, 2011 9:13 PM
  • User-1164658185 posted

    nice job.

     

    Wednesday, June 22, 2011 4:49 PM