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

xiaoxiao2021-03-06  91

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 Authors table Connection and DataAdapter string cnnString = @ "server = (local) / NetSDK; database = pubs; Integrated Security = SSPI;"; SqlConnection cnn = new SqlConnection ( CNNSTRING); SQLDataAdapter cmd1 = new SqldataAdapter ("Select * from authors", cn); // 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-100828.html

New Post(0)