开发者

Showing Details in sub Grid

开发者 https://www.devze.com 2023-03-30 06:11 出处:网络
Orders grid is containing a sub-grid for order details开发者_如何学JAVA.Normally I am doing this by implementing RowDataBound event.but I think it is bad idea to fetch order details from database for

Orders grid is containing a sub-grid for order details开发者_如何学JAVA. Normally I am doing this by implementing RowDataBound event. but I think it is bad idea to fetch order details from database for every row of orders grid. Is there a better way?

Thanks


As far as "bad idea", I assume you mean from a performance standpoint. In my opinion the scenario you describe isn't necessarily a bad idea, depending on the performance expectations of your application. The method you suggest is the easiest to implement that I can think of, and could be the best way if your page isn't going to be hit very often.

Having said that, I can think of two other ways to approach this.

1) Join your order details at the DB level, and render the table manually using a repeater, adding outer rows only when the main order record changes. This method would require only one trip to the database for each page render but requires more coding for presentation.

2) Pre-fetch all of your order details on page load into a DataTable or collection and load your details from there on your outer gridview RowDataBound. This method would also reduce trips to the database down to two (one for the orders, one for order details) but wouldn't require as much presentation coding.

0

精彩评论

暂无评论...
验证码 换一张
取 消