There will be a lotArticleThis article describes the nested datalist repeater, repeater nested repeater, and datalist nested datalist. In summary, there are several methods. If you are interested, you can add them if you have any problems.
1. Microsoft's method is to use a dataset to separately fill the data to the two tables of the dataset, and then set the relationship.
Dataset DS = New Dataset (); String Sql1 = " Select * From Province " ; Sqldataadapter sda1 = New Sqldataadapter (sql1, constring ); Sda1.fill (DS, " Province " );
String Sql2 = " Select * from City " ; Sqldataadapter sda2 = New Sqldataadapter (sql2, constring ); Sda2.fill (DS, " City " );
DS. relations. Add ( " Myrelation " , DS. Tables [ " Province " ]. Columns [ " Provinceid " ], DS. Tables [ " City " ]. Columns [ " Father " ]); Dlcategories. datasource = DS. Tables [ " Province " ]. Defaultview; Dlcategories. databind (); |
The specific method can take a look at Microsoft's knowledge base or refer to this article http://www.cnblogs.com/singlepine/archive/2006/04/03/365964.html
2. execute in the control event (itemdatabound event). Each time when the data is bound, you can use datarowview to retrieve the data of each row, and then help set the data to the embedded control.