【问题标题】:display Dataset contents into Gridview Row-wise将数据集内容显示到 Gridview Row-wise
【发布时间】:2013-12-07 13:55:40
【问题描述】:

我有一个数据集,其中每行有 3 列标题、链接和描述。这必须绑定到 Gridview。 当绑定到 Gridview 时,结果显示为 标题链接描述(即在一行中,所有三个值都显示为一个数据集行)

我需要结果显示在

    Title               
    Link
    Description

也就是说,我需要按行显示结果。

谁能告诉我如何实现它。

【问题讨论】:

    标签: asp.net gridview


    【解决方案1】:

    您可以使用模板字段来做到这一点。

    <asp:GridView ID="GridView1" runat="server" ShowHeader="false">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <table>
                        <tr>
                            <td>
                                Title
                            </td>
                            <td>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("title") %>'></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Link
                            </td>
                            <td>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("link") %>'></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Decsription
                            </td>
                            <td>
                                <asp:Label ID="Label3" runat="server" Text='<%# Bind("description") %>'></asp:Label>
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-25
      • 1970-01-01
      • 2015-03-02
      • 1970-01-01
      • 2021-01-09
      相关资源
      最近更新 更多