C# 如何使gridview和单元格变大?
我想让我的ASP gridview更宽,单元格更大。我试过一些宽度和单元格间距/单元格填充的sh*t,但都不起作用 外观: 它应该是什么样子的: gridview:C# 如何使gridview和单元格变大?,c#,css,asp.net,gridview,C#,Css,Asp.net,Gridview,我想让我的ASP gridview更宽,单元格更大。我试过一些宽度和单元格间距/单元格填充的sh*t,但都不起作用 外观: 它应该是什么样子的: gridview: <div class="content"> <%-- GridView --%> <asp:UpdatePanel ID="pnlGVList" runat="server"> <ContentTemplate> <asp:GridView runat="
<div class="content">
<%-- GridView --%>
<asp:UpdatePanel ID="pnlGVList" runat="server">
<ContentTemplate>
<asp:GridView runat="server" ID="gridList" CellPadding="40" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" DataSourceID="DSList" AllowPaging="True" PageSize="50">
<AlternatingRowStyle BackColor="White" ForeColor="#284775"></AlternatingRowStyle>
<Columns>
<asp:BoundField DataField="positie" HeaderText="Positie" SortExpression="positie"></asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="artiestid" DataNavigateUrlFormatString="Artists.aspx?id={0}" DataTextField="naam" HeaderText="Naam" />
<asp:HyperLinkField DataNavigateUrlFields="songid" DataNavigateUrlFormatString="Song.aspx?id={0}" DataTextField="titel" HeaderText="Titel" />
<asp:BoundField DataField="jaar" HeaderText="Jaar" SortExpression="jaar"></asp:BoundField>
</Columns>
<EditRowStyle BackColor="#999999"></EditRowStyle>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"></FooterStyle>
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"></HeaderStyle>
<PagerStyle HorizontalAlign="Center" BackColor="#284775" ForeColor="White"></PagerStyle>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333"></RowStyle>
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333"></SelectedRowStyle>
<SortedAscendingCellStyle BackColor="#E9E7E2"></SortedAscendingCellStyle>
<SortedAscendingHeaderStyle BackColor="#506C8C"></SortedAscendingHeaderStyle>
<SortedDescendingCellStyle BackColor="#FFFDF8"></SortedDescendingCellStyle>
<SortedDescendingHeaderStyle BackColor="#6F8DAE"></SortedDescendingHeaderStyle>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:SqlDataSource runat="server" ID="DSList" ConnectionString='<%$ ConnectionStrings:TOP2000_IAO4A_GROEP2ConnectionString %>' SelectCommand="sp_top2000_year" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="ddlJaar" PropertyName="SelectedValue" DefaultValue="" Name="YEAR" Type="Int32"></asp:ControlParameter>
</SelectParameters>
</asp:SqlDataSource>
</div>
您正在将
内容css类的边距
和填充
应用于div
,而不是行
您可以为您的行样式
创建一个css类
,并应用如下内容:
<RowStyle CssClass="myRowStyleClass"></RowStyle>
然后从网格视图中删除单元格填充
,您可以尝试以下操作:
#gridList {
margin:50px;
width:95%;
}
#gridList td { width:20%; padding: 5px;}
或者您可以单独设置每列(td
元素)的相对宽度,例如:
td:first-child {width:15%;}
td:last-child {width:16%;}
td:nth-child(2) {width:25%;}
(回复:)
希望这能有所帮助
td:first-child {width:15%;}
td:last-child {width:16%;}
td:nth-child(2) {width:25%;}