2015-06-06 31 views
1

我想让我的ASP网格视图更宽,并且单元更大。我已经尝试了一些带有宽度和cellspacing/cellpadding的sh * t,但它们都不起作用。如何使gridview和单元格更大?

如何看起来:http://prntscr.com/7dobyg

如何它几乎应该是这样的:http://prntscr.com/7dobor

GridView控件:

<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:

#gridList { 
margin:50px; 
width:2000px; 
} 

.content { 
margin-top: 30px; 
margin-left: 300px; 
margin-right: 40px; 
height: 100vh; 
background-color: white; 
box-shadow: 0px 0px 1px 1px black; 
} 

回答

1

你申请marginpaddingscontent css classdiv,而不是。

您可以为您创造一个RowStylecss class应用是这样的:

<RowStyle CssClass="myRowStyleClass"></RowStyle> 

而且从GridView删除CellPadding

1

可以尝试以下方法:

#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%;} 

(重:http://www.codeproject.com/Tips/262546/HTML-Tables-formating-best-practices)。

希望这可能有所帮助。

相关问题