开发者

Better "left / substring" solution for <%# Container.DataItem %>

This little asp.net code has some drawbacks. If the itemrow is empty, it will fail. If the item tends to be shorter than 10 chars, you already know.

开发者_开发问答
<asp:LinkButton ID="lbnHistory" CommandName="lbnHistory" 
  CommandArgument="'<%# Container.DataItem %>' 
  Text='<%# ((string)Container.DataItem).ToString().Substring(5,10) %>' 
  runat="server">
</asp:LinkButton>

I'm also available to solve this with the repeatercommandevent i use for this task. For simplification, I want it filled from a comma separated string. The task itself is so simple and not worth creating and iterating a strong type.

What do you think?


Whops, I think I was to deep into other thoughs. You just have to create a public method and wrap it into..

For the sake of clarify.. <%# SampleTruncing((string)Container.DataItem) %>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜