p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Professional (http://p2p.wrox.com/forumdisplay.php?f=63)
-   -   HOWTO Nested Grid in ASP.Net 2.0??? (http://p2p.wrox.com/showthread.php?t=41232)

ziaiz April 13th, 2006 04:28 AM

HOWTO Nested Grid in ASP.Net 2.0???
Problem 1:

i want nesting of grids like in hierarchical format (Expand-collapse) in ASP.Net 2.0, is there any trick to do that without heavy javascript or HTML? is there any way to do that using new GridView control?

i have done something like this (http://www.samspublishing.com/conten...inks/fig04.jpg)

but i want the child grid only show when i click the select button( itemcommand event) of the parent grid and only current row display the child grid not others...

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%

Problem 2:

another example i tried is http://msdn.microsoft.com/msdnmag/is...0/CuttingEdge/

it has the proper format what i want but when i connect it with my sql server data it is showing me error: "The relation is not parented to the table to which this DataView points"

my tables are:


RegionCode -RegionName
R1 -North Region
R2 -Mumbai Region
R3 -East Region
R4 -South Region
R5 -Gujarat Region
R6 -Maharashtra Region


RegionCode -ZoneCode -ZoneName
R1 -R1Z1 -Delhi NCR
R1 -R1Z2 -U.P, Bihar & Uttaranchal
R1 -R1Z3 -Haryana
R1 -R1Z4 -Punjab
R1 -R1Z5 -Chandigarh
R1 -R1Z6 -M.P.
R1 -R1Z7 -Jaipur
R2 -R2Z1 -Mumbai
R3 -R3Z1 -Kolkatta
R3 -R3Z2 -Rest of East

code is:

protected void Page_Load(object sender, System.EventArgs e)
            // Put user code to initialize the page here
            if (!IsPostBack)
                SqlDataAdapter adapter = new SqlDataAdapter(
    "SELECT * from tbl1", "SERVER=local;DATABASE=mydata0607;UID=sa;pwd=s a");

    SqlDataAdapter adapter1 = new SqlDataAdapter("select * from tbl2", "SERVER=local;DATABASE=mydata0607;UID=sa;pwd=s a");

                DataSet data = new DataSet();
                adapter.Fill(data, "tbl1");
                adapter1.Fill(data, "tbl2");

                data.Tables[0].TableName = "tbl1";
                data.Tables[1].TableName = "tbl2";

                string relName = "tbl12tbl2";
                DataRelation rel = new DataRelation(relName,

                                Cache["MyData"] = data;


        protected void UpdateView(object sender, System.EventArgs e)

        private void BindData()
            // Bind the data source
            dataGrid.DataSource = (DataSet) Cache["MyData"];
            dataGrid.DataMember = "tbl1";

            // Bind the data

//'please help me...:(

All times are GMT -4. The time now is 10:03 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.