将数据集内容显示为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 Descriptionnamely, 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>更多推荐
发布评论