开发者

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

开发者 https://www.devze.com 2023-03-02 23:39 出处:网络
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.

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

精彩评论

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

关注公众号