冻结的DataGrid列 [英] Freeze DataGrid columns

查看:164
本文介绍了冻结的DataGrid列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要冻结在ASP.NET DataGrid Web控件的第一列。

I need to freeze the first columns in a ASP.NET Datagrid web control.

我有大约20列。我使用Visual Studio 2008中

I've got approximately 20 columns. I'm using visual studio 2008.

应该是这样的Excel。还需要冷冻头为好。

It should be like Excel. Also need to freeze header as well.

任何人可以帮助我吗?

推荐答案

试试这个

<div class="container">
<asp:GridView ID="grdview_items" runat="server"
DataSourceID="SDS_items" 
EnableViewState="false" Width="800">
<HeaderStyle  CssClass="grdview_headers"  />
 <Columns>
<asp:TemplateField HeaderStyle-Width="200px" ItemStyle-Width="200px"  HeaderText="Item1"><ItemTemplate></ItemTemplate></asp:TemplateField>
<asp:TemplateField HeaderStyle-Width="300px" ItemStyle-Width="300px"   HeaderText="Item2"><ItemTemplate></ItemTemplate></asp:TemplateField>
<asp:TemplateField HeaderStyle-Width="300px" ItemStyle-Width="300px"    HeaderText="Item3"><ItemTemplate></ItemTemplate></asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<style>
.container 
{
    overflow:auto;
    margin-left:10px;
    height:300px; 
    width:710px;
 }

.grdview_headers
{
    color:#330000; 
    position:absolute;
    display:block;
    width:790px;
    margin-top:-1px;
}

</style>
<script type="text/javascript">
    $(document).ready(function () {
        $('.container tr>td:nth-child(2)').css("background-color", "#EAEAEA").css("position", "absolute");
    });
</script>

这篇关于冻结的DataGrid列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆