Use the REPEATER control to display the main - from the relational data sheet

zhaozj2021-02-16  53

This article describes a method of displaying the main - from the relational data table using the Repeater control.

Original article See: http://support.microsoft.com/default.aspx? ScID = KB; EN-US; 306154

NestedRepeater.aspx

<% @ Import namespace = "system.data"%> <% @ import name "%> <% @ page language =" c # "codebehind =" nestedrepeater.aspx.cs "autoeventwireup =" false "inherits = "EMENG.NESTEDREPEATER"%>

<% # databinder.eval (container.dataitem, "au_id")%>

public class NestedRepeater: System.Web.UI.Page {protected System.Web.UI.WebControls.Repeater parentRepeater; public void Page_Load (object sender, EventArgs e) {// Create Connection and DataAdapter string cnnString = @ "server is Authors table = (local) / NetSDK; database = pubs; Integrated Security = SSPI; "; SqlConnection cnn = new SqlConnection (cnnString); SqlDataAdapter cmd1 = new SqlDataAdapter (" select * from authors ", cnn);

// Create a populated dataset. DataSet DS = New Dataset (); cmd1.fill (DS, "Authors");

/ / Create DataAdapter SqldataAdapter CMD2 = New SqldataAdapter ("Select * from TitleAuthor"; CMD2.Fill (DS, "Titles"); cmd2.fill (DS, "Titles");

// Create the relationship between the Authors table and the Titles table. DS.RELATIONS.ADD ("MyRelation", DS.Tables ["authors"]. Column ["au_id"], ds.tables ["titles"]. Columns [ "au_id"]);

// Bind authors to the parent REPEATER PARENTREPEATER.DASOURCE = DS.TABLES ["Authors"];

cnn.Close (); cnn.Dispose ();} private void Page_Init (object sender, EventArgs e) {InitializeComponent ();} private void InitializeComponent () {this.Load = new System.EventHandler (this.Page_Load); } public nestedRepeater () {page.init = new system.eventhandler (Page_init);}}}

转载请注明原文地址:https://www.9cbs.com/read-19809.html

New Post(0)