Answered by:
Two Item in one item in repeater

Question
-
User-1698479530 posted
Hi
i would to know if there a way to bind two item in one item while it call instead of showing seperate.
ex.
Data 1
Data 2
to be
Data 1 Data 2
Saturday, June 11, 2016 1:04 PM
Answers
-
User2103319870 posted
If the data is from two columns in table, then one option is to concatenate the values in your sql query and then assign it to repeater
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, June 11, 2016 1:09 PM -
User1559292362 posted
Hi,
i would to know if there a way to bind two item in one item while it call instead of showing seperate.We know that repeater control could use custom template, you could also combine two items like this:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FristRepeaterDemo.aspx.cs" Inherits="ADONETDEMO.RepeaterDemo.FristRepeaterDemo" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Repeater ID="Repeater1" runat="server"> <HeaderTemplate> <table cellspacing="0" rules="all" border="1"> <tr> <th scope="col" style="width: 80px"> Customer Id -- Customer Name </th> <th scope="col" style="width: 120px"> Customer Name </th> <th scope="col" style="width: 100px"> Country </th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td> <asp:Label ID="lblCustomerIdContactName" runat="server" Text='<%# Eval("CustomerId") + "" + Eval("ContactName") %>' /> </td> <td> <asp:Label ID="lblContactName" runat="server" Text='<%# Eval("ContactName") %>' /> </td> <td> <asp:Label ID="lblCountry" runat="server" Text='<%# Eval("Country") %>' /> </td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater> </div> </form> </body> </html>
Best regards,
Cole Wu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, June 13, 2016 7:47 AM
All replies
-
User2103319870 posted
If the data is from two columns in table, then one option is to concatenate the values in your sql query and then assign it to repeater
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, June 11, 2016 1:09 PM -
User1559292362 posted
Hi,
i would to know if there a way to bind two item in one item while it call instead of showing seperate.We know that repeater control could use custom template, you could also combine two items like this:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FristRepeaterDemo.aspx.cs" Inherits="ADONETDEMO.RepeaterDemo.FristRepeaterDemo" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Repeater ID="Repeater1" runat="server"> <HeaderTemplate> <table cellspacing="0" rules="all" border="1"> <tr> <th scope="col" style="width: 80px"> Customer Id -- Customer Name </th> <th scope="col" style="width: 120px"> Customer Name </th> <th scope="col" style="width: 100px"> Country </th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td> <asp:Label ID="lblCustomerIdContactName" runat="server" Text='<%# Eval("CustomerId") + "" + Eval("ContactName") %>' /> </td> <td> <asp:Label ID="lblContactName" runat="server" Text='<%# Eval("ContactName") %>' /> </td> <td> <asp:Label ID="lblCountry" runat="server" Text='<%# Eval("Country") %>' /> </td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater> </div> </form> </body> </html>
Best regards,
Cole Wu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, June 13, 2016 7:47 AM