추가 하여 Database 연결 문자열을 지정하고 디자인 코드 입력
FrmRepeater.aspx |
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">
<title></title> </head> <body>
<form id="form1" runat="server">
<div>
리피터 컨트롤 사용 출력<br /><br />
<asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource1"> <HeaderTemplate> <%= SITE_NAME %><br /> </HeaderTemplate> <ItemTemplate> <%# Eval("Name") %><br /> </ItemTemplate> <AlternatingItemTemplate> <%# "<a href='View.aspx?Num='" + Eval("Num") + "'>"
+ Eval("Name")
+ "</a>" %><br /> </AlternatingItemTemplate> <SeparatorTemplate> <hr /> </SeparatorTemplate> <FooterTemplate> 꼬리말 </FooterTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Memos]"></asp:SqlDataSource>
</div>
</form> </body> </html> |
FrmRepeater.aspx.cs |
public partial class FrmRepeater : System.Web.UI.Page {
public string SITE_NAME { get; set;
} // 속성
public FrmRepeater()
{
SITE_NAME = "닷넷코리아";
}
protected void Page_Load(object
sender, EventArgs
e)
{
} } |
결과확인 |
[그림51-1] |
'ASP.NET' 카테고리의 다른 글
53.C# ASP.NET - HttpContext [상태관리1] (0) | 2009.10.20 |
---|---|
52.C# ASP.NET - Trace 추적 (0) | 2009.10.20 |
50.C# ASP.NET - DataList [DataControl 3] (0) | 2009.10.20 |
49.C# ASP.NET - FormView [DataControl 2] (0) | 2009.10.19 |
48.C# ASP.NET - SqlDataSource 와 ADO [DataControl 1] (0) | 2009.10.19 |
Comments