We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

DataGridView not displaying all columns

rowansmith
rowansmith asked
on
Medium Priority
1,082 Views
Last Modified: 2013-12-17
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.

Thanks.

-Rowan

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

Open in new window

Comment
Watch Question

Top Expert 2009

Commented:
Does your gridview have autogeneratecolumns set to "off"?
Randy Wilson.Net Developer

Commented:
Can you attach an example XML file that your are using?
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.

-Rowan

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Top Expert 2009

Commented:
What happens if you set the AutoGenerateColumns to "False"?
Top Expert 2009

Commented:
Sorry, ignore the previous comment.

Author

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:

service
AOL_Messenger  36
Authenticated 37
ClearTrust  40

members
0 36
1 37
4 40

reference
AOL 0
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:

AOL_Messenger
       AOL
       ICQ_locator

Authenitcated
     telnet
     ftp
     http
     login

ClearTrust
     trust-Auth
     Trust-Dispatch
     Network


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?

Thanks.

-Rowan
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.