Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 271511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:10:30+00:00 2026-05-12T00:10:30+00:00

Sorry if the post title wasn’t clear, I will try to explain a little

  • 0

Sorry if the post title wasn’t clear, I will try to explain a little better here.

I am working with a web control that is databound to a data table. The output of the data is as such:

<asp:Repeater ID="RssRepeater" Visible="false" EnableViewState="false" runat="server">
    <asp:literal ID="sb_description" Text='<%# DataBinder.Eval (Container.DataItem, "description") %>' EnableViewState="false" runat="server" />
    ''// Rest of structure...
</asp:Repeater>

I wrote a function that, in theory, should trim a passed string to a specified number of words:

protected string CreateTeaser(string Post)
{
    int wordLimit = 50;
    System.Text.StringBuilder oSB = new System.Text.StringBuilder();

    string[] splitBy = new string[] { " " };

    string[] splitPost = Post.Split(splitBy,
                         System.StringSplitOptions.RemoveEmptyEntries);

    for (int i = 0; i <= wordLimit - 1; i++)
    {
        oSB.Append(string.Format("{0}{1}", splitPost[i], 
                  (i < wordLimit - 1) ? " " : ""));
    }

    oSB.Append(" ...");

    return oSB.ToString();
}

I tried this abomination:

<asp:literal ID="sb_description" Text='<%= CreateTeaser(%> <%# DataBinder.Eval (Container.DataItem, "description") %><%=); %>' EnableViewState="false" runat="server" />

But of course it did not work. So, is it possible to use this function on the Databinder.Eval( ... ) while it is inside this literal control? If so, how should I go about doing this? If not, what would be a possible alternative to what I am trying to do?

Thanks SO!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T00:10:31+00:00Added an answer on May 12, 2026 at 12:10 am

    You can submit the Eval result directly to your method (using your original Eval syntax and casting to a string):

    <asp:literal 
        ID="sb_description" 
        Text='<%= CreateTeaser((string)DataBinder.Eval (Container.DataItem, "description")) %>'
        EnableViewState="false" 
        runat="server" 
    />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for the double post, I will update this question if I can't get
guys, sorry for the title of the post... i'm not so good in english,
I am sorry about the title of this post, but I've no idea how
First post here, sorry for starting with asking questions. In my Windows Phone 7
sorry if the title is a little.. vague i couldnt pin it down. So
I remade this post because my title choice was horrible, sorry about that. My
I understand the title may be a little vague, but, hopefully, I can explain
Sorry for fuzzy post title, I can't formulate the correct name in English for
(couldn't think of a better title, sorry) So I've got my layout page, on
Since the html code is so long and i can't post here. Sorry to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.