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

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1073
  • Last Modified:

DataGridView not displaying all columns

I have a datagridview that is populated from a dataset.

The dataset came from a ReadXML command ... so I have something like the code below.

When I traverse the columns in dataset1.Tables["services"], I can see the column called "service_id", however this column does not exist in the datagridview.

In addition I have another table - dataset1.Tables["references"] - again this has two columns, service_id and member_id, again when I display this I do not see the columns.

And finally another table called "member" which has the column member_id.

I understand that these are generated by the ReadXML and maintain the integrity of the datatables and how they all link together, but I want to expose the values in the datagridview, and I can not work out what is turning off the fields.



DataSet dataset1 = new DataSet();
dataGridView1.DataSource = dataset1.Tables[tableName];

Open in new window

  • 3
  • 2
1 Solution
Does your gridview have autogeneratecolumns set to "off"?
Randy Wilson.Net DeveloperCommented:
Can you attach an example XML file that your are using?
rowansmithAuthor Commented:
It is a default datagridview I do nothing to it except the code you see (assign the datasource), according to the debugger autogeneratecolumns is set to true.

The XML files are too large to post, and I really do not want to try and trim them down to an example because it will not be a real example.

dataset1.ReadXML(Filename) results in a dataset consisting of 52 tables, parent tables and child tables and tables to maintain many-to-many mappings.

After analysing the datacolumn objects in each datatable in the dataset I have determined that the value of the datacolumn.ColumnMapping is set to MappingType.Hidden.

It would appear this is done so that when the XML is written out again, (dataset.writexml) these values are not written out because they are internal.

The datagridview does not show these, setting columnmapping to mappingtype.element solves the problem and I can see the columns in the datagridview.

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

What happens if you set the AutoGenerateColumns to "False"?
Sorry, ignore the previous comment.
rowansmithAuthor Commented:
So can you help me with this, realise it is a completely different question if you can not help I will close this one and start a new one...

After ReadXML I have the following (that I am going to care about).

dataset1.Tables["service" , "members", "reference"];

So three tables which are related ....

Each tables columns/fields looks like this
service (name, service_id)
members (members_id, service_id)
reference (name, Table, members_id)

These three tables facilitate a one-many mapping of "one service"  has "many references" effectively - that much I have been able to work out...

So an example of the data looks like this:

AOL_Messenger  36
Authenticated 37
ClearTrust  40

0 36
1 37
4 40

ICQ_locator 0
telnet 1
ftp 1
http 1
login 1
Trust-Auth 4
Trust-Dispatch 4
Network 4

So in effect I have three parent objects which each has child objects like this:




I want to create a datatable that has the service.name on the left and the reference.name on the right.  How do I do this?  I notice that the dataset has quite a few DataRelation objects already created but I do not know how to integrate with these?



Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now