我对 gridview 设计有疑问,任何人都可以帮助我。 我已经创建了一个 GridView ,但是当我向该网格单元格提供任何文本时,我的网格设计正在发生变化。我的问题是如何给 gridview 一个固定的高度,即使我们将文本输入一个单元格或没有:单元格。这是我的代码。 提前致谢。
<asp:GridView ID="GrvSchoolName1" runat="server" AllowPaging="True" PageSize="4" Height="30px" BackColor="White"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3"
GridLines="Vertical" CssClass="grvclass"
AutoGenerateColumns="False"
ForeColor="Black" onpageindexchanging="GrvSchoolName1_PageIndexChanging">
<PagerSettings Mode="NumericFirstLast" PageButtonCount="4" FirstPageText="First" LastPageText="Last"/>
<AlternatingRowStyle BackColor="#CCCCCC" />
<Columns>
<asp:TemplateField HeaderText="Emergency Alert" HeaderStyle-Height="30px">
<ItemTemplate>
<div style="overflow:auto; height:60px;">
<asp:Label ID="Label1" runat="server" Text='<% #Eval("AlertMessage") %>' ></asp:Label>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
</div>
最佳答案
为您的 itemstyle 模板提供一个 CSS 类。标题同样适用:)
.NET
<ItemStyle CssClass="items"> </ItemStyle>
<ItemTemplate>
your stuff
</ItemTemplate>
CSS。
.items{width:200px;}
关于html - 在 ASP.NET 中使用 html 的 Gridview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16672158/