【发布时间】:2026-01-11 02:30:01
【问题描述】:
这是我的 ASP:
<asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateEditButton="true"
DataSourceID="AccessDataSource1"
AutoGenerateColumns="False" DataKeyNames="ID"
RowStyle-CssClass="editPhotoGridFormat"
AlternatingRowStyle-CssClass="editPhotoGridFormat"
AlternatingRowStyle-BackColor="Gray"
RowStyle-Height="400px"
RowStyle-VerticalAlign="Top">
<RowStyle Height="400px" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="BlogTitle" HeaderText="BlogTitle"
SortExpression="BlogTitle" />
<asp:ImageField DataImageUrlField="Image" HeaderText="Image"
DataImageUrlFormatString="~/PlaceImages/{0}" ControlStyle-CssClass="editPhotoGridFormat"
AlternateText="Something went wrong"
NullDisplayText="No picture on file" />
<asp:BoundField DataField="PicText" HeaderText="PicText" />
<asp:BoundField DataField="TravelDate" HeaderText="TravelDate" SortExpression="TravelDate" />
<asp:BoundField DataField="BeginText" HeaderText="BeginText" ItemStyle-Height="10px" />
<asp:BoundField DataField="Caption" HeaderText="Caption" />
<asp:BoundField DataField="City" HeaderText="City" />
<asp:BoundField DataField="Country" HeaderText="Country"
SortExpression="Country" />
<asp:BoundField DataField="EndText" HeaderText="EndText" />
</Columns>
</asp:GridView>
这是我的 CSS:
.editPhotoGridFormat
{
width: 220px;
height: 180px;
}
似乎无论我在哪里设置高度,它都不想改变我的行的高度。您可以看到我在代码中的很多地方都设置了高度,并且我已经尝试单独使用每个地方。有什么想法吗?这里所有关于gridview行高的帖子似乎都是针对Android的,哈哈。
【问题讨论】:
-
RowStyle-CssClass="editPhotoGridFormat"我能看到这个css类的内容吗? -
我运行了您提供的确切代码(使用我自己的数据源),所有单元格的高度均为 400 像素。在浏览器中运行代码,然后查看源代码。把它和你的css一起转储到一个pastebin(或fiddle)中,我会看看。
-
不知道 pastebin 是什么。我确实在 IE 中检查了它(我主要使用 Firefox)并且高度确实设置为 400px。所以看起来 Firefox 不喜欢它,这很奇怪,因为通常情况正好相反
-
在 Chrome 中也不起作用...
-
你知道,我敢打赌 Firefox 正在缓存你的页面。在Firefox中打开它,按住控制,然后按F5。然后回来汇报。仅供参考,pastebin 是一个非常酷的网站。与 jsfiddle 相同。
标签: asp.net css visual-studio-2010 gridview