且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何设置gridview行高

更新时间:2023-01-24 22:47:01

那里有很多方法

在HTML源代码中提及 RowStyle (& AlternateRowStyle )的高度值

Lot of ways there
Mention the height value for RowStyle(& AlternateRowStyle) in your HTML source
<rowstyle height="50" />



您可以在代码隐藏中执行相同操作


You can do that same in code-behind

GridView1.RowStyle.Height = 50;






但我的建议是使用CSS(***方式)




But my suggestion is use CSS(Best way)
.RowStyle {
  height: 50px;
}
.AlternateRowStyle {
  height: 50px;
}



HTML来源


HTML Source

<asp:gridview id="GridView1" runat="server" xmlns:asp="#unknown">
    RowStyle-CssClass="RowStyle"  
    AlternatingRowStyle-CssClass="AlternateRowStyle">  
</asp:gridview>






OR

<asp:gridview id="GridView1" runat="server" xmlns:asp="#unknown">
<rowstyle cssclass="RowStyle" />
<alternatingrowstyle cssclass="AlternateRowStyle" />
</asp:gridview>

>

您可以在 RowStyle 中设置高度(以及 AlternateRowStyle 如果使用的话)。如果行中的文本换行,则可以使用单元格样式 white-space:nowrap; overflow:hidden;
You can set Height in RowStyle (and AlternateRowStyle if used). If text in your row wraps, you can avoid it using cell style white-space:nowrap;overflow:hidden;.


you来避免它可以使用
you can do this using height attribute in
<alternatingrowstyle></alternatingrowstyle>

<rowstyle></rowstyle>



如下所示:


as shown below :

<AlternatingRowStyle BackColor="White" Height="50" />
           Or
<asp:BoundField ItemStyle-Height="50" ..