0

I have a GridView and in the first row I want that the lines be padded on left by 20px. I tried to do it with CSSClass but does not work.

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

with CssClass as below :

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

So what could be wrong here ?

4

2 回答 2

1

一套ItemStyle-CssClass="CellFile"_asp:boundfield

仍然没有成功,尝试改变你的css链接引用,如下所示,在末尾添加查询字符串以加载样式表。如果 css 缓存,即使您编辑 css,您也不会看到结果

<link href="/my.css?id=1" rel="stylesheet" type="text/css" />
于 2013-04-26T10:40:39.823 回答
1

如果你想在你的 CSS 中使用整个 GridView,在这种情况下只需使用 IDid="MyGridView

CSS

#MyGridView{
   your stylingoptions here;
}

如果你想改变行和列,你可以使用

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

将这两个添加到 Gridview 的 Templatefield

于 2013-04-26T10:50:00.590 回答