Click here to Skip to main content
Click here to Skip to main content

Fully functional Nested DataGrid

, 13 Mar 2006
Rate this:
Please Sign up or sign in to vote.
This application will help you to build a datagrid within a datagrid with all options like Edit, Delete and Add functionality.

Introduction

 This article will explains all the functionality of a Nested Datagrid. There are following funtionalities in the applcation :

1) Add / Edit / Delete functions for parent and child datagrids.

2) Tree view for parent datagrid.

3) validation for adding data.

Sample screenshot

Objective :

  Most of the datagrid applications are used for displaying data only. So I thought of adding the functionality (Add, Edit, Modify, Tree View) in the datagrid.

Database :

   Northwind database has been used for the ease, but you need to create two tables to run the application. Database script for the table creation is included in the zip file. The two tables used are :

1) Custs

2) Ords

 Design :

  There are two datagrids in the application, 'dgCustomer' and 'dgOrders'. 'dgCustomer' is a parent datagrid and the child datagrid 'dgOrders' is generated based on the primary key of records of 'dgCustomers'.

Events & Methods Description :

   BindData method is used for binding dgCustomer datagrid.

   dgCustomer_ItemDataBound event is used to bind orders datagrid.

   dgCustomer_ItemCommand event is used for delete & add commands of customer datagrid.

   dgCustomer_EditCommand event is used to edit data of customer datagrid.

   dgCustomer_CancelCommand event is used to cancel edited data of customer datagrid.

   dgCustomer_UpdateCommand event is used to update edited data of customer datagrid.

   dgCustomer_ItemCreated event is used to register orders datagrids events.

 

   bindOrderData method is used for binding dgOrders datagrid.

   dgOrders_ItemDataBound event is used to bind orders datagrid.

   dgOrders_ItemCommand event is used for delete & add commands of Orders datagrid.

   dgOrders_EditCommand event is used to edit data of Orders datagrid.

   dgOrders_CancelCommand event is used to cancel edited data of Orders datagrid.

   dgOrders_UpdateCommand event is used to update edited data of Orders datagrid.

 

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Dinesh Goziya
Web Developer
India India
I am a software engineer working for Microsoft Software Private Limited at Cybage Software Private Limited Pune. I have 3 Years of experience in ASP.NET and .NET Compact framework.

Comments and Discussions

 
QuestionUrjent Query regarding nested grid Pinmemberdilfizo2-Apr-12 2:11 
GeneralMy vote of 3 Pinmemberrkumar6709-Oct-11 20:03 
QuestionJScript Error PinmemberHariSir28-Nov-07 15:23 
AnswerRe: JScript Error PinmemberNadene17-Aug-09 2:58 
GeneralSetting 'Collapse' as the default when the page loads Pinmemberrabing23-Dec-06 21:00 
Generalerror while using inside usercontrol PinmemberGayuDams11-Nov-06 1:59 
GeneralRe: error while using inside usercontrol PinmemberDinesh Goziya12-Nov-06 19:47 
GeneralRe: error while using inside usercontrol PinmemberGayuDams12-Nov-06 20:04 
GeneralRe: error while using inside usercontrol PinmemberGayuDams14-Nov-06 18:22 
GeneralBinding DataList Within A DataGrid Pinmembermshariq12-Jul-06 4:47 
Hello, I m working on displaying phtos in datalist as well as datagrid. For this i created a datagrid & then add a template column in it. then in that template column i added datalist. now I wanted to display the data in the following format
Country Cities
USA Washington NewYork Las Vegas
India Dehli Mumbai Banglore
Pakistan Lahore Karachi Islamabad
 
Whenever I bind data to datalist in grid's itemdatabound column, it gives the message "Object reference not set to an instance of an object." Please sort out this prob. Here's my code of grid's itemdatabound column
Dim SizeList As DataList= e.Item.FindControl("SizeList")
Dim da As SqlDataAdapter
Dim ds As New DataSet
Dim str As String
str = "SELECT tblsizes.size_desc as [Sizes], tblorderphotos.qty as [Quantity] FROM tblsizes INNER JOIN tblorderphotos ON tblsizes.size_id = tblorderphotos.size_id INNER JOIN tblphotos ON tblorderphotos.photo_id = tblphotos.photo_id WHERE (tblorderphotos.order_id = 116) AND (tblorderphotos.photo_id = 196)"
da = New SqlDataAdapter(str, Connection.getConnection)
da.Fill(ds, da.DefaultSourceTableName)
SizeList.DataSource = ds
SizeList.DataBind()
Questionhow can I make " dgCustomer" collapse as default case! not expand when i pagelod the page!! Pinmembertiger6015-Jun-06 18:40 
AnswerRe: how can I make " dgCustomer" collapse as default case! not expand when i pagelod the page!! Pinmembertiger6015-Jun-06 18:41 
GeneralRe: how can I make " dgCustomer" collapse as default case! not expand when i pagelod the page!! Pinmemberrabing23-Dec-06 20:57 
AnswerRe: how can I make " dgCustomer" collapse as default case! not expand when i pagelod the page!! Pinmembermrhamedn7-Feb-07 1:59 
AnswerRe: how can I make " dgCustomer" collapse as default case! not expand when i pagelod the page!! Pinmembermrhamedn7-Feb-07 2:01 
AnswerRe: how can I make " dgCustomer" collapse as default case! not expand when i pagelod the page!! Pinmembermrhamedn7-Feb-07 2:02 
AnswerRe: how can I make " dgCustomer" collapse as default case! not expand when i pagelod the page!! PinmemberMember 132196630-Jul-08 10:50 
Questionwhere is the article ? Pinmemberv2.013-Mar-06 5:39 
AnswerRe: where is the article ? PinmemberRama Krishna Vavilala13-Mar-06 5:48 
GeneralRe: where is the article ? Pinmemberv2.013-Mar-06 5:51 
GeneralRe: where is the article ? PinmemberMarcello13-Mar-06 10:39 
GeneralRe: where is the article ? PinmemberHardikP15-Mar-06 4:10 
GeneralRe: where is the article ? PinmemberDinesh Goziya15-Mar-06 18:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 13 Mar 2006
Article Copyright 2006 by Dinesh Goziya
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid