|
Re: Please comment!: msg#00118windows.devel.dotnet.web
My only real criticism is that the problem you're describing can be easily solved by returning multiple result sets from your database queries, then you really don't need this control (and you don't return duplicate information in your SQL query): 1) construct a database query that returns multiple sets of data. This is a poor example but you should get the point: DECLARE @customers TABLE (CustomerID int, CustomerName varchar(255)) DECLARE @orders TABLE (CustomerID int, OrderID int OrderDate datetime) -- get the customers INSERT INTO @customers SELECT CustomerID, CustomerName FROM Customers WHERE ... -- get their orders INSERT INTO @orders WHERE CustomerID IN (SELECT CustomerID FROM @customers) -- return the results SELECT * FROM @customers SELECT * FROM @orders SELECT * FROM Comments WHERE OrderID IN (SELECT OrderID FROM @orders) 2) get the results in a dataset (which it looks like you're doing already) DataSet ds = ...; myAdapter.Fill( ds ); // create relationships between the tables myAdapter.Relationships.Add( "CustomersToOrders", ds.Tables[0].Columns[0], ds.Tables[1].Columns[0] ); myAdapter.Relationships.Add( "OrdersToComments", ds.Tables[1].Columns[1], ds.Tables[2].Columns[0] ); myRepeater.DataSource = ds.Tables[0]; myRepeater.DataBind(); 3) have a repeater set up as such: (have a @Import at the top of your page: <%@ Import Namespace="System.Data"%>) <asp:Repeater...> <ItemTemplate> <tr> <td><%#...CustomerName...%></td> <td> <asp:Repeater id="rptrCustomerOrders" runat="server" DataSource='<%# ((DataRowView)Conatiner.DataItem).Row.GetChildRows("CustomersToOrders")%>'> <div><%# ((DataRow)Container.DataItem)["OrderDate"] %></div> ... </asp:Repeater> </td> </tr> </ItemTemplate> </asp:Repeater> Granted, your databinding expressions for the innner tables are a bit different than you're probably used to (GetChildRows returns a DataRow[]), but it solves the same problem you have except your SQL query doesn't need to return duplicates and you don't need a custom control to handle it (and it takes roughly the same amount of ASPX/HTML markup to accomplish). Adam.. > -----Original Message----- > From: Discussion of building .NET applications targeted for > the Web [mailto:DOTNET-WEB@xxxxxxxxxxxxxxxxxxx] On Behalf Of > Daniel Schaffer > Sent: Thursday, June 23, 2005 7:45 AM > To: DOTNET-WEB@xxxxxxxxxxxxxxxxxxx > Subject: [DOTNET-WEB] Please comment! > > I've recently posted an article about a control I've created > on CodeProject.com. I've never had any formal training for > programming- related education, so as much as I read about > proper programming practices, I am always curious as to what > professionals think of my code. If any of you have time, I > would much appreciate any constructive criticism you may have > about my article and my work on the code. > > The article can be found here: > http://www.codeproject.com/useritems/groupingrepeater.asp =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Please comment!: 00118, Daniel Schaffer |
|---|---|
| Next by Date: | Declaratively using custom controls from the GAC: 00118, Russell McClure |
| Previous by Thread: | Please comment!i: 00118, Daniel Schaffer |
| Next by Thread: | Re: Please comment!: 00118, Daniel Schaffer |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |