[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Add a new row on a datagrid

Posted on 2006-04-26
4
Medium Priority
?
212 Views
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 ?
thanks
0
Comment
Question by:yellowflame
  • 2
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
craigwardman earned 250 total points
ID: 16547819
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?
0
 

Author Comment

by:yellowflame
ID: 16550109
I don’t need to have multiple tables…
0
 
LVL 8

Expert Comment

by:craigwardman
ID: 16550533
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..

i.e.

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

with table1
 .columns.add("FirstName")
 .columns.add("Surname")
end with

with table2
 .columns.add("Car")
 .columns.add("Colour")
end with

allData.Tables.add(table1)
allData.Tables.add(table2)

DataGridView1.DataSource=allData.DefaultViewManager.CreateDataView(allData.Tables(0))
DataGridView2.DataSource=allData.DefaultViewManager.CreateDataView(allData.Tables(1))

(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..
0
 

Author Comment

by:yellowflame
ID: 16636702
i haven't try any of the above code because i don't want to have two datagrids.

thanks a lot for your comments
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

830 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