Results 1 to 4 of 4

Thread: Nested DataTable for GridView

  1. #1
    Join Date
    May 2008
    Posts
    95

    Nested DataTable for GridView

    What I want to know is that whether we can nest two or more DataTable to use as DataSource for a GridView.

    I have a GridView where I want to display the list of training areas of a company and for each field I want to see a list of all courses that belong to that particular area using a GridView.

    The solution, according to me, is to create a DataTable that serves the fields and in each field I create a DataTable powered by the associated training.

    Unfortunately this solution did not work?

    Do you have ideas or any suggestions to achieve this?

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Nested DataTable for GridView

    There is, indeed, no doubt that you might have not done well because that's how it should proceed.

    This is a super simple case, you have 2 tables: Fields, Area in which each area corresponds to a field.

    You have a dropdown list which contains the fields and in the GridView you will display the corresponding training.

  3. #3
    Join Date
    May 2008
    Posts
    95

    Re: Nested DataTable for GridView

    What I mean is that I want the two to coexist in a single GridView.

    For example:

    I would like to have a table that contains the list of fields and in each fields I would like to have a list of areas belonging.

    Example graphically

    ------------------------------
    If | SQL Server
    | C#
    -------------------------------
    Finance | Accounting
    | Financial Analysis
    -------------------------------

    as the table is a GridView and the case of training is also a grid view. The database and the relationships between tables are correct.

    I hope I explained my problem.

  4. #4
    Join Date
    May 2008
    Posts
    271

    Re: Nested DataTable for GridView

    A hierarchical DataGrid control makes sense only if the data source is a DataSet object that contains relations between tables. For example, consider a DataSet with Customers and Orders tables with a DataRelation set between the two on the CustomerID column. As long as the DataGrid contains a button column, when you click it you could create a child view for the selected customer and bind the resulting DataView object to the child grid.

    Because the new control (named NestedGrid) inherits from the DataGrid class, you can use it whenever a DataGrid object is appropriate. In general, when you derive a control from a base class there might be situations in which the derived control can't just replace the original due to its specific extensions and additions. In this column, I won't spend much time making the NestedGrid component backward compatible with the base DataGrid class.

Similar Threads

  1. Ado.Net: Reorder columns in a DataTable
    By Sergio 1 in forum Software Development
    Replies: 3
    Last Post: 29-12-2010, 02:45 AM
  2. Confused over DataTable, DataView and DataGrid
    By Lawford in forum Software Development
    Replies: 5
    Last Post: 12-02-2010, 03:34 AM
  3. How to sort a datatable
    By Udayachal in forum Software Development
    Replies: 6
    Last Post: 23-01-2010, 01:23 PM
  4. Exporting datatable to excel with ADO.net
    By Sanket07 in forum Software Development
    Replies: 2
    Last Post: 03-02-2009, 05:52 PM
  5. How can i export datatable to excel
    By Leena in forum Software Development
    Replies: 3
    Last Post: 30-01-2009, 11:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,021,006.10445 seconds with 17 queries