GridView 自动换行
CSS
/*table begin*/ table{ border-collapse:collapse;border-spacing:0;} th,td{ margin:0;padding:0; } .tdLeftBg{ background:#EFEFEF; } .tbGvw,.tbDefault{ margin-left:auto; margin-right:auto; } .tbGvw,.tbGvw th,.tbGvw td,.tbDefault,.tbDefault th,.tbDefault td{ border:1px #CCC solid; padding:5px; text-align:center; } /*单行样式*/ .tbGvw tbody .trOdd{ background:#FFF; } /*双行样式*/ .tbGvw tbody .trEven{ background:#f3f5f2; } /*鼠标经过样式*/ .tbGvw tbody .trHover{ background:#e2e9ea; } .tbGvw tbody tr .tdLeft,.tbDefault tbody tr .tdLeft{ text-align:left; } .tbGvw .tbHeader th{font-weight:bolder;color:Black;font-size:13px; } .tbDefault thead th{ text-align:center; } .tbDefault tbody .tdRight{ text-align:right; } .tbDefault caption{ background:url(../images/admin.png) no-repeat 10px 7px; padding:10px 0 10px 35px; font-weight:bold; } /*table end*/ /*复选框*/ .tbCbl,.tbCbl td{ border:0; } .tbCbl td{ text-align:left; } .tbCbl td input{ cursor:pointer; } .tbCbl td label{ padding:0 5px; cursor:pointer; } /*单选框列表*/ .tbRadl,.tbRadl td{ border:0; } .tbRadl td{ text-align:left; } .tbRadl td input{ cursor:pointer; } .tbRadl td label{ padding:0 5px; cursor:pointer; } /*自动换行*/ .whiteSpaceNormal{white-space:normal;}
ASP.NET
<asp:GridView ID="gv_JX_JDBMX" runat="server" CssClass="tbGvw" Width="99%" AutoGenerateColumns="false" > <Columns> <asp:BoundField HeaderText="班级" ItemStyle-Width="200" ItemStyle-CssClass="tdLeft whiteSpaceNormal"/> </Columns> </asp:GridView>