申し訳ありません投稿のタイトルが明確でない場合は、ここで少し詳しく説明します。データバインドされたコンテンツをオンザフライで変更することはできますか?
データテーブルにデータバインドされているWebコントロールを使用しています。私は、この醜態を試してみました
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();
}
::私は理論的には、単語の指定された数に渡された文字列をトリミングする必要があり、機能を書いた
<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>
:のようなデータの出力がある
<asp:literal ID="sb_description" Text='<%= CreateTeaser(%> <%# DataBinder.Eval (Container.DataItem, "description") %><%=); %>' EnableViewState="false" runat="server" />
もちろん、動作しませんでした。したがって、このリテラルコントロール内にある間にDatabinder.Eval(...)
でこの関数を使用することは可能ですか?もしそうなら、私はこれをどうやって行うべきですか?そうでない場合は、私がやろうとしていることに対する可能な代替手段は何でしょうか?
ありがとうございます!
ありがとう、これは正しいトラックで私を得た:) – Anders