I am trying to get the first 50 letters, so I used the subString
function to get it.
As you can see, I used this code to get it:
<%# Eval("BannerDescription").ToString.Substring(1, 50)%>
But unfortunately it's not working and an error message is coming up:
Index and length must refer to a location within the string.
So is there any other way to fix it?
because the user is the one who is controlling the data entry! some times he gonna enter 10 letters other times maybe 1000 letter so how can i solve this ?
I tried them all but can we use it this way :
<%# IIf(Eval("BannerDescription").ToString().Length > 49, Eval("BannerDescription").ToString().Substring(0, 49), Eval("BannerDescription"))%>
Thanks.
Maybe something like this -
<%# Eval("BannerDescription").ToString().Substring(0, Math.Min(Eval("BannerDescription").ToString().Length, 50)) %>
<%# new string(Eval("BannerDescription").ToString().Take(50).ToArray()) %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With