目前出现的问题是大多数列的内容都换行,有那么一两列不换行,不知怎么回事?
我只是让他绑定了后台的数据库中的某张表而已;
前台html代码如下:
......
<tr>
<td><asp:datagrid id="DataGrid" runat="server"  BorderColor="Green" PageSize="5" AllowCustomPaging="True"
AllowPaging="True" ItemStyle-HorizontalAlign="Left" HeaderStyle-BackColor="#00ff99" ItemStyle-Wrap="true"
AutoGenerateColumns="true" AlternatingItemStyle-BackColor="#ccffff" ItemStyle-Width="100px" 
AlternatingItemStyle-Width="100px" AlternatingItemStyle-Wrap=true >
<PagerStyle Visible="False"></PagerStyle>

</asp:datagrid></td>
</tr>
........
我想让所有列换行或者都不换行,该咋办呢?谢谢高手指教!

解决方案 »

  1.   

    换行了肯定是宽度不够,把datagrid的宽度调宽,使datagrid的宽度要大于所有的列的宽度的总和
      

  2.   

    Public Function FormatStr(ByVal strValue As String, ByVal intMaxLen As Integer) As String
            If IsDBNull(strValue) Then
                FormatStr = "&nbsp;"
            ElseIf CStr(strValue).Length >= intMaxLen Then
                FormatStr = Microsoft.VisualBasic.Left(CStr(strValue), intMaxLen) & "..."
            Else
                FormatStr = CStr(strValue)
            End If
        End Function调用这个方法,把多余的字符断,太长了,还转行,看起来实在不爽的
      

  3.   

    如何控制DataGrid里的内容换行与不换行?http://dotnet.aspx.cc/ShowDetail.aspx?id=A27CA611-2DE7-432D-8DBC-1512CEFDAA53
      

  4.   

    谢谢 renyu732(在南京找工作,有招聘信息的联系[email protected]) ,
    我只是想简单设置DataGrid的属性,是否能实现?