【问题标题】:display format for gridview网格视图的显示格式
【发布时间】:2010-05-06 21:02:10
【问题描述】:

我有一个名为“GridView1”的网格包含两列“日期”和“会话详细信息”,我仅以这种方式显示:

<asp:GridView ID="GridView1" OnRowCommand="ScheduleGridView_RowCommand" 
    runat="server" AutoGenerateColumns="False" Height="60px"
    Style="text-align: center" Width="869px" EnableViewState="False">
    <Columns>
        <asp:BoundField HeaderText="Date" DataField="Date">
            <HeaderStyle Width="80px" />
        </asp:BoundField>
        <asp:BoundField DataField="" HeaderText="Session Detais" />
    </Columns>

但是在这里我需要在会话详细信息下方显示 3 个列部分,每个日期没有任何列边框,我该如何实现。

Date                                                                SessionDetails

06-04-2010                       Time-(value from database)         Topic-(value from database)    Head-(value from database)


-------                               ------------------               -------------------            ----------------------

【问题讨论】:

  • 我不知道如何在此处无边界添加子列

标签: asp.net gridview


【解决方案1】:

您将要使用TemplateField 自己定义布局。这样的事情会做到:

<asp:GridView ID="GridView1" OnRowCommand="ScheduleGridView_RowCommand" 
    runat="server" AutoGenerateColumns="False" Height="60px"
    Style="text-align: center" Width="869px" EnableViewState="False">
    <Columns>
        <asp:BoundField HeaderText="Date" DataField="Date">
            <HeaderStyle Width="80px" />
        </asp:BoundField>
        <asp:TemplateField>
            <HeaderTemplate>
                Session Details
            </HeaderTemplate>
            <ItemTemplate>
                <span class="col"><%# Eval("Time") %></span>
                <span class="col"><%# Eval("Topic") %></span>
                <span class="col"><%# Eval("Head") %></span>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

注意:如果TimeTopicHead 不同,则必须将它们替换为您的实际值。然后,您可以使用如下样式设置 3 个 span 标记的位置:

<style type="text/css">
    .col { width: 100px; float: left; }
</style>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-14
    • 1970-01-01
    • 2015-08-23
    相关资源
    最近更新 更多