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!