Follow Our FB Page << >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

HOw to Build a Nested GridView Control with ASP.NET?

Answers were Sorted based on User's Feedback

HOw to Build a Nested GridView Control with ASP.NET? ..

Answer / swapna

The steps in creating Datagrid are

1) Create a new Web page in project.
2) Add a GridView to that page.
3) Define bound columns for every element of data in

4) Convert one or more bound columns into a template column
by clicking on the tag at the top-left corner of the

5) select Edit columns from the smart menu, select the
field to convert, and click the link for converting a
bound column to a template column.

6) Close the Fields dialog.
7) Add a UserControl to your project.

8) Click the Smart tag on the GridView again and select
Edit Templates.

9) Drag and drop the UserControl from the solution explorer
to the ItemTemplate, remove the existing Label and TextBox,
and click Edit UserControl from the Smart tag menu.

10) Add a second GridView to the UserControl and you have
the basic design.

After completing all these steps code looks like

<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register Src="Orders.ascx" TagName="Orders"

<%@ Register Src="OrdersControl.ascx"
TagName="OrdersControl" TagPrefix="uc1" %>


<html xmlns="" >
<head runat="server">
<title>Untitled Page</title>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server"
Height="191px" Width="325px"
<asp:BoundField DataField="CustomerID"
HeaderText="Customer ID">
<ItemStyle VerticalAlign="Top" />
<HeaderStyle Wrap="False" />
<asp:BoundField DataField="CompanyName"
HeaderText="Company Name">
<ItemStyle VerticalAlign="Top" />
<HeaderStyle Wrap="False" />
<asp:BoundField DataField="ContactName"
HeaderText="Contact Name">
<ItemStyle VerticalAlign="Top" />
<HeaderStyle Wrap="False" />
<asp:TemplateField HeaderText="Order Shipping
<uc2:Orders ID="Orders1" runat="server"/>
<ItemStyle VerticalAlign="Top" />
<HeaderStyle Wrap="False" />


Is This Answer Correct ?    15 Yes 10 No

HOw to Build a Nested GridView Control with ASP.NET? ..

Answer / geo

i gave general solution
Nesting GridView controls in ASP.NET were described in that
almost “canonical” Microsoft walkthrough [1]. In general,
it requires creating of two GridView controls: the first
one serving as a container or master GridView1 with its own
DataSource1 (SqlDataSource, AccessDataSource, etc.) and
second "nested" GridView2 with its underlying DataSource2
residing within a TemplateField in master GridView1.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More ASP.NET Code Interview Questions

Coding for .NET Delegates?

0 Answers  

Code for Creating a Form Using PlaceHolder Controls?

0 Answers   Arena, JSA,

how to create a search bar which access data from various websites and retrieves the data

0 Answers  

How to add checkbox to datagrid?

5 Answers  

i have a gird with columns all are coming from database,this will bind in item templete in gridview as textboxex.and i have button below named Update.i want to update all the records in the grid,but if user change the value of one textbox,what is the easy way 2 do this

0 Answers   Crompton Greaves,

Code for Document Validation in XML.NET?

0 Answers   TCS,

How to use Client-side Script to Focus Controls in ASP.NET?

0 Answers  

What do you create for easier access of data?

3 Answers   NIIT,

How to Snap the Cursor to a Button?

1 Answers  

what is software testing

1 Answers   TCS,

Data Reader Vs DataSet

5 Answers   TCS,

Code for Presenting Parent/Child Data in a Data Grid Row?

0 Answers   TCS,

  • ASP.NET Code Interview Questions ASP.NET Code (46)
  • VB.NET Code Interview Questions VB.NET Code (9)
  • C Sharp Code Interview Questions C Sharp Code (51)
  • ADO.NET Code Interview Questions ADO.NET Code (8)