请问如何冻结DataGrid中的列啊??
比如前面一列或多列固定不动,后面的出现滚动条??

解决方案 »

  1.   

    应该不能实现吧,可以考虑用Table代替,来实现复杂的布局DataGrid和DataList最终在浏览器中呈现时也是转换为Table的,Table是万能的
      

  2.   

    纯脚本搞掂DataGrid表表头不动,表身滚动。 
     
            function ScrollDataGrid() 
            { 
                var tb = document.getElementById("tbHeader"); 
                var dg = document.getElementById("dgSearchResult"); 
                 
                if(dg!= null) 
                {     
                    var dv = document.getElementById("dvBody"); 
                    var th = dg.rows[0]; 
                    for(var i = 0 ; i < th.cells.length;i++) 
                        th.cells[i].width = th.cells[i].clientWidth; 
                    var tr = th.cloneNode(true); 
                     
                    //tr.applyElement(tb); 
                    tb.createTHead(); 
                    var tbh = tb.tHead; 
                    tbh.appendChild(tr); 
                    tr = tbh.rows[0]; 
                    var td = tr.insertCell(); 
                    td.style.width = 19; 
                    td.width = 19; 
                    td.innerHTML = tr.cells[0].innerHTML; 
                    th.style.display = 'none'; 
                    if(dg.scrollHeight < 300 ) 
                        dv.style.height = dg.scrollHeight * 1 + 2; 
                     
                     
                }                 <table width="100%" border="0" id="tbHeader" cellpadding="4" cellspacing="0"> 
                                            </table> 
                                            <div style="OVERFLOW-Y: scroll; HEIGHT: 300px" id="dvBody"> 
                                                <asp:datagrid id="dgSearchResult" style="BORDER-COLLAPSE: collapse" runat="server" Width="100%" CellPadding="4" DataKeyField="编号" BorderWidth="1px" BorderStyle="Solid" BorderColor="RoyalBlue" GridLines="None"> 
                                                    <SelectedItemStyle ForeColor="SlateGray"></SelectedItemStyle> 
                                                    <ItemStyle VerticalAlign="Middle"></ItemStyle> 
                                                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle> 
                                                    <Columns> 
                                                        <asp:ButtonColumn Text="选择" HeaderText="&lt;font face=webdings&gt;6&lt;/font&gt;" CommandName="Delete"> 
                                                            <HeaderStyle Wrap="False" Width="40px"></HeaderStyle> 
                                                            <ItemStyle Wrap="False" HorizontalAlign="Center"></ItemStyle> 
                                                            <FooterStyle Wrap="False"></FooterStyle> 
                                                        </asp:ButtonColumn> 
                                                    </Columns> 
                                                </asp:datagrid></div>  
      

  3.   

    个人意见:可以用两个DataGrid
      

  4.   

    http://community.csdn.net/Expert/TopicView3.asp?id=3911839
    可能有你的答案的思路
      

  5.   

    http://www.codeproject.com/aspnet/FreezePaneDatagrid.asp
    用这个,可以实现
      

  6.   

    http://www.cnblogs.com/goody9807/archive/2005/08/30/225872.html
    刚写的文章