<a href="http://www.micropoll.com/akira/mpview/585320-168921">Click Here for Poll</a><a href="http://www.questionpro.com" title="online surveys">Online Survey</a><BR> | <a href="http://www.micropoll.com" title="Website Polls">Website Polls</a><BR> | <BR><a href="http://www.micropoll.com/akira/MicroPoll?mode=html&id=168921">View MicroPoll</A></div>

Visual Studio 2010!

Read now >

Windows Mobile Development Thoughts

Read now >

View Now
DevSource RSS FEEDS
XML Want an easy way to keep up with breaking tech news? And the Get DevSource headlines delivered to your desktop with RSS.
ADVERTISEMENT
ADVERTISEMENT

 

DevSource.com: Your Source for Visual Studio on Facebook
ADVERTISEMENT
Master-Detail Nested Grids with DevExpress' ASPxGridView
By Paul Kimmel

Rate This Article: Add This Article To:

Master-Detail Nested Grids with DevExpress' ASPxGridView - Essential Properties
( Page 4 of 5 )

Configuring Essential Nesting Properties and Storing the Session Variable

To wrap up you need to select the nested grid (Order Details) in the Properties window, expand the SettingsDetail property and change the sub-property IsDetailGrid to True (see Figure 6). In the grid containing Orders open the Property window, expand SettingsDetail and set ShowDetailRow to True, and add the code in Listing 1.


Figure 6: Set SettingsDetail|IsDetailGrid to true for the ASPxGridView representing the nested grid.

Listing 1: One line of code stuffs the master grid’s key into session to correlate the master grid with each child grid containing Order Details.

Imports DevExpress.Web.ASPxGridView
Partial Public Class _Default
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    End Sub
  Protected Sub ASPxGridView2_BeforePerformDataSelect(ByVal sender As Object, _
    ByVal e As EventArgs)
    Session("OrderID") = CType(sender, ASPxGridView).GetMasterRowKeyValue()
  End Sub
End Class

Create an event handler for the detail grid’s BeforePerformDataSelect event and obtain the primary key for Orders by calling the GebtMasterRowKeyValue and storing it in the Session variable (OrderID) created in the Data Source wizard. When you run the example the results should look consistent with Figure 7.


Figure 7: Order Details nested in the Orders ASPxGrdView with the first Order expanded to show the nested grid.



 
 
>>> More Microsoft and Visual Studios Add Ons Articles          >>> More By Paul Kimmel