Display 30 left crs from the databinder.eval

Posted on 2012-09-13
Last Modified: 2012-09-17
HOw do I display only the first 30 chrs of the ITemdescription field in the following: Is there a way to do a left or Right in HTML
  <td  width="60%" align="left">
                    <asp:Label ID="Label2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ItemDescription") %>'></asp:Label>
Question by:TrialUser
    LVL 13

    Accepted Solution

    I'm not an ASP expert, but I think you are looking for:

    <%# DataBinder.Eval(Container.DataItem, "ItemDescription").ToString().Substring(0, 30) %>
    LVL 16

    Assisted Solution

    by:Rose Babu

    you cal also try Left function in .net as mentioned in the below link

    Sample code:

    <asp:Label ID="Label2" runat="server" Text='<%# Left(DataBinder.Eval(Container.DataItem, "ItemDescription"), 30) %>'></asp:Label>


    try a small function that will truncate the word upto n characters and put some continuation dots.

    Below is the link for this process.

    put the Chop() function in your code and use it.

    Sample code :

    <asp:Label ID="Label2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ItemDescription").ToString().Chop(30) %>'></asp:Label>

    Hope these additional info may help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
    The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now