How to freeze first column of each row in gridview?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NareshN
    New Member
    • Aug 2010
    • 45

    How to freeze first column of each row in gridview?

    Hi All,


    I am trying freez first column of each row in gridview using Css but it is not working.


    Code:
    <link href="Includes/Styles1.css" rel="stylesheet" type="text/css" />
    
        <title>Untitled Page</title>
        <style type="text/css">
            div#div-datagrid
            {
                width: 220px;
                height: 100px;
                overflow: auto;
                scrollbar-base-color: #ffeaff;
            }
            /* Locks the left column */td.locked, th.locked
            {
                font-size: 14px;
                font-weight: bold;
                text-align: center;
                background-color: navy;
                color: white;
                border-right: 1px solid silver;
                position: relative;
                cursor: default; /*IE5+ only*/
                left: expression(document.getElementById(  "div-datagrid" ).scrollLeft-2);
            }
    
    
            /* Locks table header */th
            {
                font-size: 14px;
                font-weight: bold;
                text-align: center;
                background-color: navy;
                color: white;
                border-right: 1px solid silver;
                position: relative;
                cursor: default; /*IE5+ only*/
                top: expression(document.getElementById(  "div-datagrid" ).scrollTop-2);
                
                z-index: 5;
            }
            /* Keeps the header as the top most item. Important for top left item*/th.locked
            {
                z-index: 99;
            }
            /* DataGrid Item and AlternatingItem Style*/.GridRow
            {
                font-size: 10pt;
                color: black;
                font-family: Arial;
                background-color: #ffffff;
                height: 35px;
            }
            .GridAltRow
            {
                font-size: 10pt;
                
                color: black;
                
                font-family: Arial;
                background-color: #eeeeee;
                height: 35px;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div id="div-datagrid">
            <asp:GridView  ID="GridView1" runat="server" 
                onrowdatabound="GridView1_RowDataBound1" 
                onselectedindexchanged="GridView1_SelectedIndexChanged">
            </asp:GridView>
        </div>
        </form>
    </body>
    Last edited by Markus; Feb 2 '11, 10:59 AM. Reason: Added [code] tags
Working...