C# 使用Linq数据源在GridView中进行文字换行
我对word包装Gridview有问题。Gridview的源是在LinqDataSourceLog_选择方法中构建的Linq源。我有一个我想用word包装的列,但我想因为我绑定Gridview的方式,列计数总是0,所以我不能包装我没有的东西。以下是网格的标记C# 使用Linq数据源在GridView中进行文字换行,c#,asp.net,visual-studio,linq,gridview,C#,Asp.net,Visual Studio,Linq,Gridview,我对word包装Gridview有问题。Gridview的源是在LinqDataSourceLog_选择方法中构建的Linq源。我有一个我想用word包装的列,但我想因为我绑定Gridview的方式,列计数总是0,所以我不能包装我没有的东西。以下是网格的标记 <asp:GridView ID="GridViewLog" Width="200px" runat="server" CellPadding="4" AllowPagi
<asp:GridView ID="GridViewLog" Width="200px" runat="server" CellPadding="4" AllowPaging="true"
DataSourceID="LinqDataSourceLog" ShowHeader="true" AllowSorting="true" OnPageIndexChanging="GridViewLog_PageIndexChanging"
EnableModelValidation="True" AutoGenerateColumns="true" ForeColor="#333333" GridLines="Both"
Height="164px" OnRowDataBound="GridViewLog_RowDataBound" RowStyle-Wrap="true" AlternatingRowStyle-Wrap="true"
PageSize="10" PagerSettings-Mode="Numeric" OnPreRender="GridViewLog_Prerender">
<EmptyDataTemplate>
<table>
<tr>
<td style="color: #003366">
<strong>Either the applied filter returned no results or<br />
the Out of office log is currently empty .</strong>
</td>
</tr>
</table>
</EmptyDataTemplate>
<AlternatingRowStyle BackColor="White" Wrap="false" />
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" CssClass="pagination" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" Wrap="false" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
应用的筛选器未返回结果或
外出日志当前为空。
提前感谢您的帮助。网格视图中Columns集合的Count属性仅统计您在标记中指定的声明列数。当您指定
AutoGenerateColumns=“true”
时,这些列将不被计数
作为
GridViewLog.Columns.Count
的替代方法,使用GridViewLog.HeaderRow.Cells.Count
时会得到什么结果?这将告诉您所有列的计数,无论是否自动生成。非常好。我得到了正确的列数,但是仍然无法包装列。我尝试了GridViewLog.HeaderRow.Cells[6]。Wrap=true;但是没有用。