2011-08-30 47 views
0

使用repeter来显示数据,但有时数据很大以显示在单元格中。我可以使用一种方法来允许收割者显示一个字符串的前100个字符,然后用一个超链接显示下一个页面吗?欢迎任何帮助!显示字符串的前100个字符,然后超链接显示下一页

+0

有关:http://stackoverflow.com/questions/5234441/how-to-display-the-first-100-characters-in- a-gridview – onof

回答

0

你可以离开这个逻辑视图:

<asp:Label runat="server" 
Text='<%# DataBinder.Eval(Container.DataItem, "your_text_field").ToString().Substring(0, Math.Min(100, DataBinder.Eval(Container.DataItem, "your_text_field").ToString().Length %>' /> 
<asp:Hyperlink runat="server" Test='<%# Eval("your_text_field") %>' 
    Visible='<%# Eval("your_text_field").ToString().Length > 100 %>' /> 
+0

它会在Math.Min – reshma

+0

附近的标签给出一个错误'常量换行符',如果您打破了行复制或者如果您错过了引号,就会发生这种情况。 – onof

+0

谢谢.my问题现在得到解决。 – reshma

1

你没有你的代码的实现细节,所以这是一个黑暗中的镜头。如果您绑定的对象,创建一个新的属性,可以取信息的前100个字符要显示:

class Foo 
{ 
    public String PropertyData {get;set;} //your real data; 
    public String DisplayData //bind the reader to this property instead. 
    { 
     get 
     { 
      return PropertyData.substring 
      (0, (PropertyData.Length >= 100) ? 100 : PropertyData.Length); 
     } 
    } 
} 

你可以有你想要的属性什么回报,这仅仅是如何让一个例子它只显示100个字符。