repeat.aspx.cs
资源名称:论坛源码.rar [点击查看]
上传用户:scene123
上传日期:2010-02-19
资源大小:3311k
文件大小:2k
源码类别:
.net编程
开发平台:
C#
- using System;
- using System.Data;
- using System.Data.SqlClient;
- using System.Web;
- using System.Web.SessionState;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace kuangren
- {
- /// <summary>
- /// repeat 的摘要说明。
- /// </summary>
- public class repeat : System.Web.UI.Page
- { protected System.Web.UI.WebControls.Repeater parent;
- private void Page_Load(object sender, System.EventArgs e)
- {
- //Create the connection and DataAdapter for the Authors table.
- SqlConnection cnn = new SqlConnection("server=(local);database=pubs;uid=sa;pwd=wang;");
- SqlDataAdapter cmd1 = new SqlDataAdapter("select * from authors",cnn);
- //Create and fill the DataSet.
- DataSet ds = new DataSet();
- cmd1.Fill(ds,"authors");
- //Create a second DataAdapter for the Titles table.
- SqlDataAdapter cmd2 = new SqlDataAdapter("select * from titleauthor",cnn);
- cmd2.Fill(ds,"titles");
- //Create the relation bewtween the Authors and Titles tables.
- ds.Relations.Add("myrelation",
- ds.Tables["authors"].Columns["au_id"],
- ds.Tables["titles"].Columns["au_id"]);
- //Bind the Authors table to the parent Repeater control, and call DataBind.
- parent.DataSource = ds.Tables["authors"];
- Page.DataBind();
- //Close the connection.
- cnn.Close();
- }
- #region Web 窗体设计器生成的代码
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
- //
- InitializeComponent();
- base.OnInit(e);
- }
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- }
- }