Limiting characters brought back from a datalist.

Discussion in 'ASP .Net' started by Roffers, Sep 18, 2006.

  1. Roffers

    Roffers Guest

    Hi everyone.

    I've got this problem that I really have no idea how to solve.

    I have a datalist that brings back x amount of rows, I need to limit
    this datalist by 100 characters and then append a "..." to the end.

    <asp:DataList id="dlDataList" runat="server"
    RepeatDirection="Horizontal" RepeatLayout="Flow">
    <ItemTemplate>
    <asp:LinkButton Runat="server"
    ID="lnkbtn1"><%#DataBinder.Eval(Container.DataItem,
    "vc_desc")%></asp:LinkButton>
    </ItemTemplate>
    <AlternatingItemTemplate>
    , <asp:LinkButton Runat="server"
    ID="lnkbtn2"><%#DataBinder.Eval(Container.DataItem,
    "vc_desc")%></asp:LinkButton>
    </AlternatingItemTemplate>
    </asp:DataList>

    You'll see that the list currently gets rendered like
    Item1, Item2, Item3, Item4

    I need it to be
    Item1, Item2, Item3, Ite...

    Can anyone point me in the right direction?

    Any help would be appreciated.
    Mark
    Roffers, Sep 18, 2006
    #1
    1. Advertising

  2. Roffers

    jb Guest

    Roffers wrote:
    > Hi everyone.
    >
    > I've got this problem that I really have no idea how to solve.
    >
    > I have a datalist that brings back x amount of rows, I need to limit
    > this datalist by 100 characters and then append a "..." to the end.
    >
    > <asp:DataList id="dlDataList" runat="server"
    > RepeatDirection="Horizontal" RepeatLayout="Flow">
    > <ItemTemplate>
    > <asp:LinkButton Runat="server"
    > ID="lnkbtn1"><%#DataBinder.Eval(Container.DataItem,
    > "vc_desc")%></asp:LinkButton>
    > </ItemTemplate>
    > <AlternatingItemTemplate>
    > , <asp:LinkButton Runat="server"
    > ID="lnkbtn2"><%#DataBinder.Eval(Container.DataItem,
    > "vc_desc")%></asp:LinkButton>
    > </AlternatingItemTemplate>
    > </asp:DataList>
    >
    > You'll see that the list currently gets rendered like
    > Item1, Item2, Item3, Item4
    >
    > I need it to be
    > Item1, Item2, Item3, Ite...
    >
    > Can anyone point me in the right direction?
    >
    > Any help would be appreciated.
    > Mark
    >

    Mark

    You need to add handler for the itemdatabound event. There are plenty of
    examples around.

    jai
    jb, Sep 18, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hans Deragon
    Replies:
    2
    Views:
    436
    GrayGeek
    Oct 11, 2003
  2. Paul
    Replies:
    3
    Views:
    134
    dotnettester
    Jul 7, 2005
  3. Replies:
    3
    Views:
    133
    Aaron Bertrand [SQL Server MVP]
    Sep 18, 2006
  4. Adam Fine
    Replies:
    3
    Views:
    130
    SonOfLilit
    Mar 21, 2007
  5. Rogue Chameleon

    Limiting characters in a text box

    Rogue Chameleon, Nov 18, 2004, in forum: Javascript
    Replies:
    10
    Views:
    153
    Rob B
    Nov 23, 2004
Loading...

Share This Page