日期:2014-05-19  浏览次数:20472 次

.net初学,请问 GridView如何固定行高。在线等,UP有分。
GridView   默认行少怀行多时,高度不同   希望行高固定。

------解决方案--------------------
帮你up
------解决方案--------------------
CSS...
------解决方案--------------------
item - height
------解决方案--------------------
itemstyle - height
------解决方案--------------------
在GridView 中设置Height
------解决方案--------------------
属性RowStyle-> Height
------解决方案--------------------
<asp:GridView ID= "GridView1 " runat= "server " AutoGenerateColumns= "False " DataKeyNames= "ProductID "
DataSourceID= "SqlDataSource1 " RowStyle-Height=50>
<Columns>
<asp:BoundField DataField= "ProductID " HeaderText= "ProductID " InsertVisible= "False "
ReadOnly= "True " SortExpression= "ProductID " />
<asp:BoundField DataField= "ProductName " HeaderText= "ProductName " SortExpression= "ProductName " />
<asp:BoundField DataField= "SupplierID " HeaderText= "SupplierID " SortExpression= "SupplierID " />
<asp:BoundField DataField= "CategoryID " HeaderText= "CategoryID " SortExpression= "CategoryID " />
<asp:BoundField DataField= "QuantityPerUnit " HeaderText= "QuantityPerUnit " SortExpression= "QuantityPerUnit " />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID= "SqlDataSource1 " runat= "server " ConnectionString= " <%$ ConnectionStrings:NorthwindConnectionString %> "
SelectCommand= "SELECT [ProductID], [ProductName], [SupplierID], [CategoryID], [QuantityPerUnit] FROM [Alphabetical list of products] ">
</asp:SqlDataSource>
------解决方案--------------------
up
------解决方案--------------------
<asp:GridView ID= "GridView1 " runat= "server " OnRowDataBound= "GridView1_RowDataBound ">
<Columns>
<asp:BoundField DataField= "id " HeaderText= "编号 ">
<ItemStyle Height= "20px " />
</asp:BoundField>
</Columns>
</asp:GridView>
------解决方案--------------------
一、脚本中设置ItemStyle Height= " "中的值
二、写一个函数,在程序中作为gridview加载时的激发事件