Nested Repeaters and SqlDataSource Parameters

后端 未结 5 1257
耶瑟儿~
耶瑟儿~ 2020-12-07 02:18

I am using nested repeaters to build a table for reasons I won\'t discuss here, but what I\'m looking to do is have two datasources, one for the top level repeater that will

5条回答
  •  失恋的感觉
    2020-12-07 02:43

    You may want to look into a technique that will reduce the amount of sproc calls. It is possible to return multiple resultsets from the same stored procedure. The .net dataset has the ability to define relationships between multiple data tables, making it easy to take a datarow in one table and get all of the child nodes in another data table. Ex:

    exampleData.Relations.Add(New DataRelation("FOO_RELATION", exampleData.Tables["TABLE_A"].Columns["ID"], exampleData.Tables["TABLE_B"].Columns["PARENT_ID"]));
    

    Then from any datarow in TABLE_A you can access all of the children like this:

    DataRow[] childRows = row.GetChildRows("FOO_RELATION");
    

    This is more efficient and IMHO is easier as well. This way you don't need to bake sproc calls into the event handlers for your repeater.

提交回复
热议问题