GridView 对于长字段省略显示

代码:

    <asp:GridView ID="gvO" runat="server" AllowPaging="True" AutoGenerateColumns="False"
        AllowSorting="True" Width="1080px" PageSize="20">
        <Columns>
            <asp:TemplateField HeaderText="工程名称">
                <ItemTemplate>
                    <asp:Label ID="labProject_Name" runat="server" Width="100%" Text='<%# Convert.ToString(Eval("project_name_c")).Length>12?Convert.ToString(Eval("project_name_c")).Substring(0,12)+".":Eval("project_name_c") %>'
                        ToolTip='<%# Eval("project_name_c") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

posted @ 2013-04-26 14:13  爱智旮旯  阅读(517)  评论(0编辑  收藏  举报