Add a new row on a datagrid

Posted on 2006-04-26
Last Modified: 2010-04-23
Hi I’m trying to create and add a new row on my datagrid. The type of this row is different from all the other rows on my datagrid. It’s like a new header. I already have a header. If there is a way to have multiple headers that would work too. when I try to add a new row inside the datagrid_ItemDataBound() method the first record on my datagrid was not shown.. any help ?
Question by:yellowflame
    LVL 8

    Accepted Solution

    Although you can add many tables into one dataset, as far as I know its not possible to have multiple tables as the datasource for one datagrid..

    You will need multiple datagrid.. Consider loading them at runtime maybe?

    Author Comment

    I don’t need to have multiple tables…
    LVL 8

    Expert Comment

    The headers of a datagrid represent the column names of the schema of the table which the datagrid represents, in order to have rows which follow a different schema would require a different table, but you cant show both tables in the same grid..

    If that is what you were after..


    Dim table1 as DataTable
    Dim table2 as DataTable
    Dim allData as DataSet

    with table1
    end with

    with table2
    end with



    (code untested, so may not compile)

    If however, you want to have another row of column headers that fit the same schema as the original data and also all the rows following the header fit the same schema, then you could just insert the header row as a normal row and then change the DefaultCellStyle on that row to make it look different from a normal cell..

    Author Comment

    i haven't try any of the above code because i don't want to have two datagrids.

    thanks a lot for your comments

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    This video discusses moving either the default database or any database to a new volume.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now