将数据集内容显示为Gridview逐行显示(display Dataset contents into Gridview Row

编程入门 行业动态 更新时间:2024-10-26 20:22:10
将数据集内容显示为Gridview逐行显示(display Dataset contents into Gridview Row-wise)

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

我需要显示结果

Title Link Description

即,我需要按行显示结果。

有人可以告诉我如何实现它。

I have a dataset,where each row has 3 columns title,link and description. This has to be binded to Gridview. When binded to Gridview the result is displayed as Title Link Description ( that is in one row, all three values are displayed for one dataset row)

I need the result to display in

Title Link Description

namely, i need the result to be displayed row-wise.

Can someone please tell me how to implement it.

最满意答案

您可以使用templatefield执行此操作。

<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>

You can do this by using templatefield.

<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>

更多推荐

本文发布于:2023-08-06 07:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1445037.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内容   数据   Gridview   display   contents

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!