html - 在 ASP.NET 中使用 html 的 Gridview

标签 html css gridview

我对 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/

相关文章:

jquery - iOS HTML Web App (PhoneGap) 过度滚动

.net GridView OnRowUpdating 未获取 TextBox 的当前值

html - 当我缩小网页时,为什么我的 2 个组件在 bootstrap 中相互重叠?

html - 单独使用css画圆

html - 无法移动显示 block 中的图像?

javascript - html页面在DOM操作过程中晃动很大,如何处理?

javascript - 如何让子菜单出现在主菜单下方

css - 在 css 中重定向到仅使用 css 的移动友好页面

c# - 从 url 值导航 gridview 页面

c# - 如何知道 GridView 的 ItemTemplate 中服务器控件的 id?