是否可以在GridView的单元格中滚动? [英] Is it possible to scroll in a cell of a gridview?

查看:103
本文介绍了是否可以在GridView的单元格中滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在gridview中有一些记录。但是每条记录都有一个问题,一个单元包含大量的数据。我仍然希望显示数据并允许用户向下滚动阅读(如果他们感兴趣)。有没有可能允许在该单元格中滚动?

I have some records in my gridview. But there is a problem in each record, there is one cell which contains a HUGE amount of data. I still want to display data and allow the users to scroll down to read (if they're interested). Is there a possibility to allow scrolling in that cell?

编辑:

这是我参考的CSS :

This is the css I refer to:

    .AspNet-GridView
    {
        overflow: auto;
        height:400px;
    }
    .AspNet-GridView table thead tr th
    {
        height:20px;
        position:relative;
    }
    .AspNet-GridView table tbody
    {
        overflow: auto;
    }

编辑2:
这是gridview,我希望列

EDIT 2: this is the gridview and I want The column with the headertext body to allow scrolling.

<asp:GridView ID="gvAanvragen" 
    OnPageIndexChanging="GvAanvragen_PageIndexChanging" runat="server" AllowPaging="True" 
    AllowSorting="True" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" 
    BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical" 
    PageSize="5" AutoGenerateColumns="false" AutoGenerateSelectButton="True" 
        onselectedindexchanged="GvAanvragen_SelectedIndexChanged" 
        CssClass="AspNet-GridView">
    <RowStyle BackColor="#F7F7DE" />
    <FooterStyle BackColor="#CCCC99" />
    <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
    <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
    <AlternatingRowStyle BackColor="White" />
    <Columns>
        <asp:BoundField HeaderText="ID" DataField="ID" />
        <asp:BoundField HeaderText="Subject" DataField="Subject" />
        <asp:BoundField HeaderText="Body" DataField="Body" HtmlEncode="false" />
        <asp:BoundField HeaderText="Sent" DataField="Sent" />
    </Columns>
</asp:GridView>

有人可以帮我吗?

Can someone help me please?

推荐答案

要添加到Naveed的答案,现在您已经发布了您的原始代码: http://www.asp.net/data-access/tutorials/using-templatefields-in-the-gridview-control-cs 有一个很好的数据绑定模板字段示例:

To add to Naveed's answer, now that you've posted your original code: http://www.asp.net/data-access/tutorials/using-templatefields-in-the-gridview-control-cs has a good example of a data bound template field:

<asp:TemplateField HeaderText="FirstName" SortExpression="FirstName">
    <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
    </ItemTemplate>
</asp:TemplateField>

在您的情况下,只需更换

In your case, just replace the line

<asp:BoundField HeaderText="Body" DataField="Body" HtmlEncode="false" />

由代码Naveed提供,并添加数据绑定,如本例中所示, :

by the code Naveed provided, and add the databinding as in this example, and you endup with something like:

<asp:TemplateField HeaderText="Body">
    <ItemTemplate>
        <div style="overflow:auto; height: 100px;">
            <asp:Label ID="Label1" runat="server" Text='<%# Bind("Body")%>'></asp:Label>
        </div>
    </ItemTemplate>
</asp:TemplateField>

如果您不想使用标签,请改为使用文字控件:

If you don't want to use a label, then use a literal control instead:

<asp:Literal ID="Literal1" runat="server" Text='<%# Bind("Body")%>' />

这篇关于是否可以在GridView的单元格中滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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