ASP.NET DataGrid,在將數據綁定到GridView之後,如何調整列標題寬度,使其不被包裝。ASP.NET DataGrid標題寬度
這裏是背後
using (SqlConnection _conn = new SqlConnection(_sqlServer))
{
using (SqlCommand _cmd = _conn.CreateCommand())
{
_cmd.CommandText =
"select * from Clients order by ID desc";
using (SqlDataAdapter _da = new SqlDataAdapter(_cmd))
{
DataSet _ds = new DataSet();
_da.Fill(_ds);
gvClients.DataSource = _ds.Tables[0];
gvClients.DataBind();
}
}
}
代碼的.aspx
<asp:GridView ID="gvClients" runat="server">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID"/>
<asp:BoundField DataField="Client" HeaderText="Client" SortExpression="Client" />
<asp:BoundField DataField="ClientID" HeaderText="Client ID" SortExpression="ClientID" />
<asp:BoundField DataField="ContactInfo" HeaderText="Contact Info" SortExpression="ContactInfo" />
<asp:BoundField DataField="AssignedTech" HeaderText="Assigned Tech" SortExpression="AssignedTech" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
</Columns>
</asp:GridView>
我已經試過
<asp:BoundField DataField="ContactInfo" HeaderText="Contact Info" ItemStyle-Width = "300px" SortExpression="ContactInfo" />
<asp:BoundField DataField="ContactInfo" HeaderText="Contact Info" HeaderStyle-Width="300px" SortExpression="ContactInfo" />
你有任何可能重寫或與這些寬度值衝突的CSS?具體來說,任何與'th'或'td'有關的CSS? –