2013-04-26 21 views
0

我有一個GridView,並在第一行我想要的行左20px填充。我試圖用CSSClass做,但不起作用。CssClass的ItemStyle不起作用

<div class="rounded-corners"; style=" margin-left:50px; margin-right:50px; "> 
     <asp:GridView id="MyGridView"   
     DataSourceID="MyDataSource1" 
     AutoGenerateColumns="False" 
     GridLines="None" 
     AllowSorting="True" 
     AllowPaging="True" 
     CssClass="mGrid" 
     PagerStyle-CssClass="pgr" 
     AlternatingRowStyle-CssClass="alt" 
     Runat="Server" PageSize="35" HorizontalAlign="Justify" 
      onselectedindexchanged="MyGridView_SelectedIndexChanged" 
      onrowdatabound="MyGridView_RowDataBound">   
      <PagerSettings FirstPageText="Début" LastPageText="Fin" NextPageText="Suivant" 
       PageButtonCount="15" PreviousPageText="Précedent" /> 
      <columns> 
       <asp:boundfield datafield="FICHIER" 
       readonly="true"  
       headertext="Fichier"> 
       <ItemStyle CssClass="CellFile" /> 
       </asp:boundfield> 
       ..... 
       ..... 
       ..... 

用的CssClass如下:

<style type="text/css"> 
    .CellFile 
    { 
     padding-left:100px; 
     margin-left:100px; 
     color:Lime; 
     background-color:Red; 
    } 
</style> 

那麼,什麼可能是錯在這裏?

+0

定義CSS類像.rounded來訪者的模板列.mGrid .CellFile – 2013-04-26 10:53:47

+0

我甚至刪除了所有定義的類除.CellFile,仍然不起作用。 – 2013-04-26 11:00:45

回答

1

設置ItemStyle-CssClass="CellFile"asp:boundfield

仍然沒有成功,嘗試改變你的CSS像下面鏈接引用,在結尾處加上查詢字符串來加載樣式表。如果CSS緩存即使你編輯CSS,你將不會看到的結果

<link href="/my.css?id=1" rel="stylesheet" type="text/css" /> 
+0

不起作用,我已經試過了。 – 2013-04-26 10:45:11

1

如果你想整個GridView控件在你的CSS只使用ID在這種情況下id="MyGridView

CSS

#MyGridView{ 
    your stylingoptions here; 
} 

如果您要更改行和或列,您可以使用

HeaderStyle-CssClass="head" <!--For the header--> 
ItemStyle-CssClass="items" <!--For the items--> 

廣告這兩種以你的GridView

+0

我只想填充第一列的行而不是所有的列。並且不起作用。 – 2013-04-26 10:58:18

+0

將'ItemStyle-CssClass'添加到你的綁定的模板字段或任何東西,並在你的css中設置:'.items {你的樣式;}' – DiederikEEn 2013-04-26 11:01:08

相關問題