首页 > 代码库 > GridView TemplateField 内容自动换行

GridView TemplateField 内容自动换行

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GuideProblemFeedback.aspx.cs"
    Inherits="LinkPower.OutSourcing.DiseaseManage.GuideProblemFeedback" %>

<%@ Register Src="http://www.mamicode.com/PubControls/PageControl.ascx" TagName="page" TagPrefix="lk" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>任务报表</title>
    <link href="http://www.mamicode.com/css/main.css" type="text/css" rel="stylesheet" />
    <link href="http://www.mamicode.com/css/main.css" type="text/css" rel="stylesheet" />

    <script src="http://www.mamicode.com/script/jquery-1.5.1.js" type="text/javascript"></script>

    <script src="http://www.mamicode.com/script/alertWin.js" type="text/javascript"></script>

    <script src="http://www.mamicode.com/script/DiseaseManage.js"></script>

    <script src="http://www.mamicode.com/script/CheckText.js" type="text/javascript"></script>

    <script src="http://www.mamicode.com/script/PD_LKPduOA5_ModInterFaceScript.js" type="text/javascript"></script>

    <script src="http://www.mamicode.com/script/LKSys_WindowControlScript.js" type="text/javascript"></script>

    <link href="http://www.mamicode.com/TaskManage/overflow-scroll-color.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .titletd
        {
            text-align: center;
            border-right: solid 1px Silver;
            background: url(../images/tableToolbarBg.gif) repeat-x left top;
        }
        td
        {
            white-space: nowrap;
        }
        .row5
        {
            background-color: #fff;
            height: 25px;
        }
        .row2
        {
            background: #dddddd;
            height: 25px;
        }
        .brk1      {        word-wrap: break-word;        word-break: break-all;      }
    </style>

    <script language="javascript" type="text/javascript">
        $(function() {
            SetHeight();

        });
        window.onresize = SetHeight;
        function SetHeight() {
            $("#divContent").height($(window).height() - 75);
        }
    </script>

</head>
<body style="overflow: hidden">
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <!--头-->
    <table class="tbToolbar" width="100%" border="0" cellspacing="0" cellpadding="0"
        id="tableTitle">
        <tr>
            <td>
                <img src="http://www.mamicode.com/images/mainToolbar.gif" />&nbsp;督导问题反馈
            </td>
        </tr>
    </table>
    <!--工具条-->
    <table id="tableSearch" width="100%" border="0" align="center" cellpadding="0" cellspacing="0"
        class="tbToolbar">
        <tr>
            <td align="left" style="vertical-align: middle; height: 25px;">
                年份:<asp:DropDownList ID="ddlYear" runat="server" CssClass="input" Width="70px">
                </asp:DropDownList>
                季度:<select id="ddlQuarter" class="input" runat="server" style="width: 70px;">
                    <option value=http://www.mamicode.com/‘‘>请选择"ddlMonth" class="input" runat="server" style="width: 70px;">
                    <option value="">请选择</option>
                    <option value="http://www.mamicode.com/1">1</option>
                    <option value="http://www.mamicode.com/2">2</option>
                    <option value="http://www.mamicode.com/3">3</option>
                    <option value="http://www.mamicode.com/4">4</option>
                    <option value="http://www.mamicode.com/5">5</option>
                    <option value="http://www.mamicode.com/6">6</option>
                    <option value="http://www.mamicode.com/7">7</option>
                    <option value="http://www.mamicode.com/8">8</option>
                    <option value="http://www.mamicode.com/9">9</option>
                    <option value="http://www.mamicode.com/10">10</option>
                    <option value="http://www.mamicode.com/11">11</option>
                    <option value="http://www.mamicode.com/12">12</option>
                </select><!--过滤的是督导日期-->
                条线:<asp:DropDownList ID="ddlLine" class="input" runat="server" Width="70px">
                </asp:DropDownList>
                执行部门:<input id="txtDeptcontent" runat="server" class="input" /><img src="http://www.mamicode.com/images/toolbar/open.gif"
                    id="img1" onclick="LKPDUOA5_SelSingleDept(‘hiddenDept‘,‘txtDeptcontent‘)" title="选择"
                    style="cursor: pointer" alt="选择" /><input type="hidden" runat="server" id="hiddenDept" />
            </td>
            <td align="right">
                <asp:Button ID="btnSearch" class="button" runat="server" Text="查询" OnClick="btnSearch_Click">
                </asp:Button>
                &nbsp;<asp:Button class="button" Text="导出Excel" ID="Button1" runat="server" OnClick="btnExport_Click" />&nbsp;
            </td>
        </tr>
    </table>
    <asp:UpdatePanel ID="Content" runat="server">
        <ContentTemplate>
            <div id="divContent" style="width: 100%; overflow: scroll;" runat="server">
                <asp:GridView ID="DgTaskComment" runat="server" Width="100%" CssClass="darkrow2"
                    AutoGenerateColumns="False" RowStyle-Wrap="true" Style="word-break: keep-all;
                    word-wrap: normal">
                    <RowStyle CssClass="row2" />
                    <AlternatingRowStyle CssClass="row5" />
                    <Columns>
                        <asp:TemplateField HeaderText="序号" Visible="false">
                            <HeaderStyle HorizontalAlign="Center" Wrap="false" Height="25" />
                            <ItemStyle HorizontalAlign="Center" Wrap="false" Height="24" />
                            <ItemTemplate>
                                <%#((this.pageion.PageIndex - 1) * this.pageion.PageSize + Container.DataItemIndex + 1).ToString()%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField HeaderText="月份" DataField="督导日期" DataFormatString="{0:MM月}" />
                        <asp:BoundField HeaderText="执行部门" DataField="执行部门" />
                        <asp:TemplateField HeaderText="执行人">
                            <ItemTemplate>
                                <span title=‘<%# Eval("执行人") != DBNull.Value && Eval("执行人") != null && Eval("执行人").ToString() != "" ?(Eval("执行人").ToString().EndsWith(",")? Eval("执行人").ToString().Substring(0, Eval("执行人").ToString().Length - 1):Eval("执行人").ToString()) : ""%>‘>
                                    <%# Eval("执行人") != DBNull.Value && Eval("执行人") != null && Eval("执行人").ToString() != "" ?(Eval("执行人").ToString().Length>12? (Eval("执行人").ToString().Substring(0,10)+"..."):Eval("执行人").ToString()) : ""%>
                                </span>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField HeaderText="条线" DataField="条线" />
                        <asp:BoundField HeaderText="督导日期" DataField="督导日期" />
                        <asp:BoundField HeaderText="医疗机构" DataField="医疗机构" />
                        <asp:BoundField HeaderText="问题来源" DataField="问题来源" />
                        <asp:TemplateField HeaderText="问题描述" HeaderStyle-Width="250px" HeaderStyle-HorizontalAlign="Center"
                            ItemStyle-Width="250px" ItemStyle-Wrap="true" ItemStyle-CssClass="brk1" ItemStyle-HorizontalAlign="Left">
                            <ItemTemplate>
                               <%# Eval("问题描述").ToString() %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <%--<asp:BoundField HeaderText="问题描述" DataField="问题描述" />--%>
                        <asp:BoundField HeaderText="整改意见" DataField="整改意见" />
                        <asp:BoundField HeaderText="整改期限" DataField="整改期限" />
                        <asp:BoundField HeaderText="是否需要跟踪" DataField="是否需要跟踪" />
                        <asp:BoundField HeaderText="跟踪结果" DataField="跟踪结果" />
                    </Columns>
                    <EmptyDataTemplate>
                        <div style="color: Red; text-align: center; width: 100%;">
                            没有要显示的记录
                        </div>
                    </EmptyDataTemplate>
                </asp:GridView>
            </div>
            <!--分页控件-->
            <lk:page ID="pageion" runat="server" PageSize="20" />
            <input type="hidden" runat="server" id="hidHasData" />
            <asp:Button ID="Btnrefresh" runat="server" OnClick="BtnRefresh" Style="display: none" />
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>



GridView TemplateField 内容自动换行