473,399 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Trying to link DataGrideTableStyle to DataGrid

Hi all

First off, thank you for any one that can help.

I have a problem trying to link a DataGrideTableStyle to a DataGrid.

I have a dataset which reads from a file a xml schema and a xml file. This
is done using the ReadXmlSchema and ReadXml.

I then create a DataTable to get access to the tables in the data set.

I then use the DataTable to get one of the tables (there are 2 tables it
holds) and use the DataGride.SetDataBinding to link the datagrid to the
table. It is at this point the error occurs saying

An Unhandled exception of type 'System.ArgumentException' occurred in
System.windows.forms.dll

Additional information: Cannot create a child list for field ShoppintItem.

From what I have been reading I need to use the SetDataBinding because when
I come to use a DataGrideTableStyle that tablestyle needs to be linked using
its MappingName to the dataGrid's DataMember.

I am doing all this so that in the datagride I can hide/Delete some columns
that I don't want to show up.

Below is the code I am using.

Thx for taking the time to read this and help.

Scott.
ds = new DataSet();

ds.ReadXmlSchema(@"C:\Document and Settings. . . . . ");
ds.ReadXml(@"C:\Documents and Settings . . . . ");

System.Data.DataTable dt = new DataTable();

// just checking they are there
string tn = ts.Tables[0].TableName;
string TN = ds.Tables[1].TableName;

System.Data.DataTable DT = ds.Tables[1];

dataGrid1.SetDataBinding(DT, DT.TableName); // <--- Error occurs here.

System.Windows.Forms.DataGridTableStle ts = new DataGrideTableStyle();
ts.MappingName = dataGrid1.DataMember;
DataGrid1.TableStyles.Add(ts);
Nov 17 '05 #1
2 1530
Hi,

"scott" <sc***********@hotmail.com> wrote in message
news:dj**********@news6.svr.pol.co.uk...
Hi all

First off, thank you for any one that can help.

I have a problem trying to link a DataGrideTableStyle to a DataGrid.

I have a dataset which reads from a file a xml schema and a xml file. This
is done using the ReadXmlSchema and ReadXml.

I then create a DataTable to get access to the tables in the data set.

I then use the DataTable to get one of the tables (there are 2 tables it
holds) and use the DataGride.SetDataBinding to link the datagrid to the
table. It is at this point the error occurs saying

An Unhandled exception of type 'System.ArgumentException' occurred in
System.windows.forms.dll

Additional information: Cannot create a child list for field
ShoppintItem.

From what I have been reading I need to use the SetDataBinding because
when
I come to use a DataGrideTableStyle that tablestyle needs to be linked
using
its MappingName to the dataGrid's DataMember.

I am doing all this so that in the datagride I can hide/Delete some
columns
that I don't want to show up.

Below is the code I am using.

Thx for taking the time to read this and help.

Scott.
ds = new DataSet();

ds.ReadXmlSchema(@"C:\Document and Settings. . . . . ");
ds.ReadXml(@"C:\Documents and Settings . . . . ");

System.Data.DataTable dt = new DataTable();

// just checking they are there
string tn = ts.Tables[0].TableName;
string TN = ds.Tables[1].TableName;

System.Data.DataTable DT = ds.Tables[1];

dataGrid1.SetDataBinding(DT, DT.TableName); // <--- Error occurs here.
It is either :
dataGrid1.SetDataBinding(DT, "");
-or-
dataGrid1.SetDataBinding(ds, DT.TableName);

You could also use dataGrid1.DataSource/DataMember in the same way.

System.Windows.Forms.DataGridTableStle ts = new DataGrideTableStyle();
ts.MappingName = dataGrid1.DataMember;
No, it needs to be the name of the table (which can but doesn't need to be
the same as the DataMember)
ts.MappingName = DT.TableName;
HTH,
Greetings

DataGrid1.TableStyles.Add(ts);

Nov 17 '05 #2
Thank you for your quick responce and fix.

It all works now.
"Bart Mermuys" <bm*************@hotmail.com> wrote in message
news:ul**************@tk2msftngp13.phx.gbl...
Hi,

"scott" <sc***********@hotmail.com> wrote in message
news:dj**********@news6.svr.pol.co.uk...
Hi all

First off, thank you for any one that can help.

I have a problem trying to link a DataGrideTableStyle to a DataGrid.

I have a dataset which reads from a file a xml schema and a xml file. This is done using the ReadXmlSchema and ReadXml.

I then create a DataTable to get access to the tables in the data set.

I then use the DataTable to get one of the tables (there are 2 tables it
holds) and use the DataGride.SetDataBinding to link the datagrid to the
table. It is at this point the error occurs saying

An Unhandled exception of type 'System.ArgumentException' occurred in
System.windows.forms.dll

Additional information: Cannot create a child list for field
ShoppintItem.

From what I have been reading I need to use the SetDataBinding because
when
I come to use a DataGrideTableStyle that tablestyle needs to be linked
using
its MappingName to the dataGrid's DataMember.

I am doing all this so that in the datagride I can hide/Delete some
columns
that I don't want to show up.

Below is the code I am using.

Thx for taking the time to read this and help.

Scott.
ds = new DataSet();

ds.ReadXmlSchema(@"C:\Document and Settings. . . . . ");
ds.ReadXml(@"C:\Documents and Settings . . . . ");

System.Data.DataTable dt = new DataTable();

// just checking they are there
string tn = ts.Tables[0].TableName;
string TN = ds.Tables[1].TableName;

System.Data.DataTable DT = ds.Tables[1];

dataGrid1.SetDataBinding(DT, DT.TableName); // <--- Error occurs here.


It is either :
dataGrid1.SetDataBinding(DT, "");
-or-
dataGrid1.SetDataBinding(ds, DT.TableName);

You could also use dataGrid1.DataSource/DataMember in the same way.

System.Windows.Forms.DataGridTableStle ts = new DataGrideTableStyle();
ts.MappingName = dataGrid1.DataMember;


No, it needs to be the name of the table (which can but doesn't need to be
the same as the DataMember)
ts.MappingName = DT.TableName;
HTH,
Greetings

DataGrid1.TableStyles.Add(ts);


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Henry | last post by:
I hope someone can help me on this. I have two controls on a form. the first is a comboBox the second is a datagrid. Both controls are bound to tables in a common dataset. What I am trying to...
2
by: Paul | last post by:
Hi, I'm pretty new to ASP.NET so not even sure how to do this correctly. On a webpage I want to display a table with rows of data from a database table (that bit I can do using datagrids etc). ...
2
by: Luis E Valencia | last post by:
I want a row of the datagrid with a personalized link. The fields of the link are on the select related to the datagrid the link would be accoiones.aspx?iddireccion=2&idindicador=5 I tried...
0
by: Luis E Valencia | last post by:
Read from above to top. I didnt understand. This is the code that fills that datagrid Public Sub pasar(ByVal sender As System.Object, ByVal e As...
5
by: Luis E Valencia | last post by:
I need a link on a datagrid, the link must have fields of the database Like this acciones.aspx?iddireccion=1&idindicador=4 Thanks
2
by: JenHu | last post by:
hi, I have a datagrid in my asp.net application, I am using vb.net language. I want to have my last column as a link column, link to text file. The link path is "c:\Temp\" & F_File_Name, which...
2
by: Its_Me_SunnY | last post by:
Hi, can any one help me how to make a cell in data grid link to another page.... like i have a field "refno" in my table so when in get the values from table to datagrid the refno's of every...
1
by: VanZandt | last post by:
I have a class(dll) that extends winform datagrid to provide link column in vb.net. I have managed to create a datagrid in c# winforms that shows link in one of the column but when I try to create a...
11
by: =?Utf-8?B?TWlrZSBDb2xsaW5z?= | last post by:
I am trying to get the text of an item in a GridView, but am doing something wrong. Can someone help me with the correct C# statement I need? Below is my GridView and my attempt to get the control....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.