【问题标题】:Label control in ItemTemplate tag in TemplateField tag in Gridview controlGridview 控件中的 TemplateField 标记中的 ItemTemplate 标记中的标签控件
【发布时间】:2011-01-12 21:04:25
【问题描述】:

我在 Gridview 控件的 TemplateField 标记中使用 ItemTemplate 标记中的标签控件来显示我的数据库的数据字段。 如果数据长度超过 100 个字符,我希望标签控件不显示所有数据。

<ItemTemplate>
<asp:Label ID="label4" runat="server" Text='<%# Bind("Description") %>' Width="200px" Font-Names="B Nazanin" EnableTheming="false" Height="24px" BorderStyle="Dashed"></asp:Label>
</ItemTemplate>

我该怎么办?

【问题讨论】:

    标签: asp.net gridview itemtemplate


    【解决方案1】:

    这是最简单的方法:

    Text='<%# Eval("Description").ToString().Substring(0, 100) %>'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-07
      • 2011-02-20
      相关资源
      最近更新 更多