Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 514219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:30:07+00:00 2026-05-13T07:30:07+00:00

Does anybody know a gridview for c# web applications or ajax that shows data

  • 0

Does anybody know a gridview for c# web applications or ajax that shows data as a tree?

For example I have some general information about contacts and I want to show each row has extra information like activity for that contact and ability to hide or show extra information.

Ordering to relational database model!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:30:07+00:00Added an answer on May 13, 2026 at 7:30 am

    Have it from somewhere in the inet… I think it was from Dino Esposito this control…

    // The DataSource SHOULD BE a DataSet. 
    // No check is implemented on this point.
    
    namespace EnterpriseUtilities.Webcontrols
    {
        /// <summary>
        /// Creates a nested data grid.
        /// </summary>
        public class NestedDataGrid : System.Web.UI.WebControls.DataGrid
        {
            /// <summary>
            /// The width.
            /// </summary>
            public Unit HostColumnWidth;
            private DataGrid detailsGrid;
            /// <summary>
            /// Gets or sets the item to render expanded.
            /// </summary>
            public int ExpandedItem
            {
                get {return Convert.ToInt32(ViewState["ExpandedItem"]);}
                set {ViewState["ExpandedItem"] = value;}
            }
            /// <summary>
            /// Gets or sets whether the child grid is scrollable or pageable
            /// </summary>
            public bool ScrollChildren
            {
                get {return Convert.ToBoolean(ViewState["ScrollChildren"]);}
                set {ViewState["ScrollChildren"] = value;}
            }
            /// <summary>
            /// Gets or sets the name of the DataSet's relation to use to fill the subgrid.
            /// </summary>
            public string RelationName
            {
                get {return Convert.ToString(ViewState["RelationName"]);}
                set {ViewState["RelationName"] = value;}
            }
            /// <summary>
            /// Fire the UpdateView event to the page for binding.
            /// </summary>
            public event EventHandler UpdateView;
            private void OnUpdateView()
            {
                if (UpdateView != null)
                    UpdateView(this, EventArgs.Empty); 
            }
            /// <summary>
            /// Public ctor
            /// </summary>
            public NestedDataGrid() : base()
            {
                ExpandedItem = -1;
                HostColumnWidth = Unit.Pixel(150);
                ScrollChildren = true;
    
                AllowPaging = true;
                PageIndexChanged += new DataGridPageChangedEventHandler(NestedDataGrid_PageIndexChanged);
                ItemCommand += new DataGridCommandEventHandler(NestedDataGrid_ItemCommand);
                ItemDataBound += new DataGridItemEventHandler(NestedDataGrid_ItemDataBound);
            }
            /// <summary>
            /// Page change handler.
            /// </summary>
            /// <param name="sender">The sender.</param>
            /// <param name="e">The page changed event.</param>
            private void NestedDataGrid_PageIndexChanged(object sender, DataGridPageChangedEventArgs e)
            {
                CurrentPageIndex = e.NewPageIndex;
                SelectedIndex = -1;
                EditItemIndex = -1;
                ExpandedItem = -1;
    
                OnUpdateView();
            }
            /// <summary>
            /// Command handler.
            /// </summary>
            /// <param name="source">The sender.</param>
            /// <param name="e">The event args.</param>
            private void NestedDataGrid_ItemCommand(object source, DataGridCommandEventArgs e)
            {
                if (e.CommandName != "Expand")
                    return;
    
                ExpandItem(e.Item);
            }
            /// <summary>
            /// Adjust the index of the expanded item.
            /// </summary>
            /// <param name="item">The item.</param>
            private void ExpandItem(DataGridItem item)
            {
                if (item.ItemIndex == (ExpandedItem % this.PageSize))
                    SetExpandedItem(item, false);
                else
                    SetExpandedItem(item, true);
    
                OnUpdateView();
            }
            /// <summary>
            /// Adjust the index of the expanded item
            /// </summary>
            /// <param name="item">The item.</param>
            /// <param name="expand">If true then item is expanded.</param>
            private void SetExpandedItem(DataGridItem item, bool expand)
            {
                if (expand)
                    ExpandedItem = (this.PageSize*this.CurrentPageIndex+item.ItemIndex); 
                else
                    ExpandedItem = -1;
            }
            /// <summary>
            /// Opens the subtree and shows the related records.
            /// </summary>
            /// <param name="item">The item.</param>
            /// <param name="columns">The associated columns.</param>
            protected override void InitializeItem(DataGridItem item, DataGridColumn[] columns)
            {
                for (int i=0; i<columns.Length; i++)
                {
                    TableCell cell = new TableCell();
                    if (columns[i] is ExpandCommandColumn)
                        ((ExpandCommandColumn)columns[i]).InitializeCell(cell, i, item.ItemType, (item.ItemIndex==(ExpandedItem % this.PageSize)));
                    else
                        columns[i].InitializeCell(cell, i, item.ItemType);
                    item.Cells.Add(cell);
                }
            }
            /// <summary>
            /// Modify the layout of the cell being expanded.
            /// </summary>
            /// <param name="sender">The sender.</param>
            /// <param name="e">The event args.</param>
            private void NestedDataGrid_ItemDataBound(object sender, DataGridItemEventArgs e)
            {
                // Process only items and alternating items
                if (e.Item.ItemType != ListItemType.Item &&
                    e.Item.ItemType != ListItemType.AlternatingItem)
                    return;
    
                // Default if the item doesn't have to be expanded
                if (e.Item.ItemIndex != (ExpandedItem % this.PageSize))
                {
                    // Instead of itemstyle-width set declaratively
                    e.Item.Cells[1].Width = HostColumnWidth;
    
                    return;
                }
    
                // Build the subtree
                BuildChildLayout(e.Item);
            }
            /// <summary>
            /// Modify the layout of the cell being expanded.
            /// </summary>
            /// <param name="item">The item.</param>
            private void BuildChildLayout(DataGridItem item)
            {
                DataGridItem row = item;
    
                // Assumes the Expand column is the first
    
                // Remove all cells but one
                int cellsToSpanOver = row.Cells.Count-1;
                ArrayList listOfText = new ArrayList();
                ArrayList listOfWidth = new ArrayList();
                for (int i=row.Cells.Count-1; i>0; i--)
                {
                    listOfText.Add(row.Cells[i].Text);
                    if (i==1) // Add the width of the column whose width is not declared
                        listOfWidth.Add(HostColumnWidth);
                    else
                        listOfWidth.Add(this.Columns[i].ItemStyle.Width);
                    row.Cells.RemoveAt(i);
                }
    
                // Add the new cell that will host the child grid
                TableCell newCell = new TableCell();
                newCell.ColumnSpan = cellsToSpanOver;
                newCell.BackColor = Color.SkyBlue;
    
                // MUST BE empty. If you set a fixed width declaratively that value
                // will override this one. For this reason, we set the width of the 
                // first column after the EXPAND column dynamically. We also assume
                // that the first column after the EXPAND column is the host cell, where
                // the child grid is inserted.
                newCell.Width = Unit.Empty;
                row.Cells.Add(newCell);
    
                // The child layout is made of a 2-row table: header (same as the 
                // previous unexpanded row) and the subgrid
                Table t = new Table();
                t.Font.Name = this.Font.Name;
                t.Font.Size = this.Font.Size;
                t.CellSpacing = this.CellSpacing;
                t.CellPadding = this.CellSpacing;
                t.BorderWidth = this.BorderWidth;
    
                TableRow rowHeader = new TableRow();
                t.Rows.Add(rowHeader);
                TableRow rowSubGrid = new TableRow();
                t.Rows.Add(rowSubGrid);
                newCell.Controls.Add(t);
    
                // Fill the header row
                for (int i=listOfText.Count-1; i>=0; i--)
                {
                    TableCell c = new TableCell();
                    c.Text = listOfText[i].ToString();
                    c.Width = (Unit) listOfWidth[i];
                    rowHeader.Cells.Add(c);
                }
    
    
                // Fill the second row
                Panel outerPanel = null;
                if (ScrollChildren)
                {
                    outerPanel = new Panel();
                    outerPanel.Height = Unit.Pixel(100);
                    outerPanel.Style["overflow"] = "auto"; 
                }
    
                TableCell cellSubGrid = new TableCell();
                cellSubGrid.ColumnSpan = cellsToSpanOver;
                cellSubGrid.BackColor = Color.LightCyan;
                rowSubGrid.Cells.Add(cellSubGrid);
    
                detailsGrid = new DataGrid();
                detailsGrid.ID = "detailsGrid";
                detailsGrid.BackColor = Color.LightCyan;
                detailsGrid.Font.Name = this.Font.Name;
                detailsGrid.Font.Size = this.Font.Size;
                detailsGrid.HeaderStyle.Font.Bold = true; 
                detailsGrid.Width = Unit.Percentage(100);
    
                if (!ScrollChildren)
                {
                    detailsGrid.AllowPaging = true;
                    detailsGrid.PageSize = 5;
                    detailsGrid.PageIndexChanged += new DataGridPageChangedEventHandler(detailsGrid_PageIndexChanged);
                }
                BindDetails(detailsGrid);
    
                if (ScrollChildren)
                {
                    outerPanel.Controls.Add(detailsGrid);
                    cellSubGrid.Controls.Add(outerPanel);
                }
                else
                {
                    cellSubGrid.Controls.Add(detailsGrid);
                }
            }       
            /// <summary>
            /// Bind the child view to the subgrid.
            /// </summary>
            /// <param name="detailsGrid">The grid.</param>
            private void BindDetails(DataGrid detailsGrid)
            {
                DataSet ds = (DataSource as DataSet);
                if (ds == null)
                    return;
    
                DataTable dt = ds.Tables[this.DataMember];
                DataView theView = new DataView(dt);
                DataRowView drv = theView[ExpandedItem];     
                DataView detailsView = drv.CreateChildView(this.RelationName);
    
                detailsGrid.DataSource = detailsView;
                detailsGrid.DataBind();
            }
            /// <summary>
            /// Takes care of paging the child grid.
            /// </summary>
            /// <param name="sender">The sender.</param>
            /// <param name="e">The event args.</param>
            private void detailsGrid_PageIndexChanged(object sender, DataGridPageChangedEventArgs e)
            {
                DataGrid detGrid = (DataGrid) sender;
                detGrid.CurrentPageIndex = e.NewPageIndex;
                //Page.Trace.Warn("Child grid page: " + detGrid.CurrentPageIndex.ToString());
                BindDetails(detGrid);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 256k
  • Answers 256k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use $('myElement').fade('toggle')`; it will automatically fade in and fade out… May 13, 2026 at 10:34 am
  • Editorial Team
    Editorial Team added an answer Remember to wrap your results in the jQuery wrapper to… May 13, 2026 at 10:34 am
  • Editorial Team
    Editorial Team added an answer Use the Changes view. In the group by directory mode… May 13, 2026 at 10:34 am

Related Questions

I'm having trouble creating a Gridview that can span 2 rows for each record.
I have a ListView in WPF that is databound to a basic table that
I have a asp:GridView which contains a asp:TextBox within a TemplateField. I would like
does anybody know when the columns are generated of a GridView? After what event?
I have standard .net 2.0 gridview control from which i want to get row

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.