在GridView中将列显示为一行 [英] display a column as a row in a GridView

查看:71
本文介绍了在GridView中将列显示为一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家,

在Gridview中,假设我有列[ID,Name,Grade,Age,Notes]

注释字段很大,很多信息。

我想将Notes字段显示为一行。是否可以这样做?

所以它会是这样的[ID,姓名,等级,年龄]

和下面[注释]



请指教



谢谢

Samira

Hi Experts,
In a Gridview let's say I have columns [ID, Name, Grade, Age, Notes]
Notes field is a big one, a lot of information.
I want to display Notes field as a row. Is it possible to do it?
so it will be something like this [ID, Name, Grade, Age]
and underneath [Notes]

Please advise

Thank you
Samira

推荐答案

使用 GridView 完成这种布局是很棘手的,但是对于 ListView [ ^ ]。 :)



ListView Web服务器控件概述 [ ^ ]



That sort of layout is tricky to accomplish with a GridView, but almost trivial to do with a ListView[^]. :)

ListView Web Server Control Overview[^]

<asp:ListView id="GradeList" runat="server">
<LayoutTemplate>
    <table>
    <thead>
        <tr>
            <th scope="col">ID</th>
            <th scope="col">Name</th>
            <th scope="col">Grade</th>
            <th scope="col">Age</th>
        </tr>
    </thead>
    <tbody>
        <tr id="itemPlaceholder" runat="server" />
    </tbody>
    </table>
</LayoutTemplate>
<ItemTemplate>
    <tr>
        <th scope="row">
            <asp:Literal runat="server" Mode="Encode"

                Text='<%# Eval("ID") %>'

            />
        </th>
        <td>
            <asp:Literal runat="server" Mode="Encode"

                Text='<%# Eval("Name") %>'

            />
        </td>
        <td>
            <asp:Literal runat="server" Mode="Encode"

                Text='<%# Eval("Grade") %>'

            />
        </td>
        <td>
            <asp:Literal runat="server" Mode="Encode"

                Text='<%# Eval("Age") %>'

            />
        </td>
    </tr>
    <tr>
        <td colspan="4">
            <asp:Literal runat="server" Mode="Encode"

                Text='<%# Eval("Notes") %>'

            />
        </td>
    </tr>
</ItemTemplate>
</asp:ListView>


这篇关于在GridView中将列显示为一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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