473,322 Members | 1,268 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,322 software developers and data experts.

DataView Question

Hello,

I have a situation that I wish some help with. I have a DataSet object with DataTables populated from a ms access database. Each DataTable has a RunLogTitle. I have a TreeView object with TreeNodes that correspods to the Names of each DataTable's RunLogTitle. When the user clicks on a TreeNode the corresponding DataTable shows up in the DataGrid.

This is working great, but I would want to use a DataView object to show only the components of each DataTable in the DataGrid. I am using a DataGridTableStyle object to then create DataGridColumnStyles.

Here is the problem, in the DataGridTableStyle I have set the MappingName to a DataView object that I have created in the constructor, here is the code that appears in the constructor of the class:
this.myDataView = new DataView(new DataTable);
this.MyDataView.Table.TableName = "MyDataView";

When the form opens up, the DataGrid is populated with the appropriate DataView and the appropriate DataGridColumnStyles only showing the data I wish to show up. HOwever when I click on a different TreeNode, I get an error message stating that "MyDataView" already belongs to the DataSet.

I have been going nuts on trying to solve this, how can I set the DataView to show the other DataTale without getting this message? This is the best way that I can describe this problem, if anyone out there can help me with this I'll greatly appreicate it!

thanks,
ed
Nov 16 '05 #1
2 2447
Hi there,

what you need is not to set the table name every time, but simply assign the
new one to the dataGridTableStyle's mapping name right after setting the new
datasource.

dataGrid1.DataSource = new DataView(dataTable2, ....);
dataGridTableStyle1.MappingName = dataTable2.TableName;

This should work.

Good luck,
Branimir

--
Branimir Giurov
MCSD.NET, MCDBA
www.sofiadev.org

"Ed_P." <Ed*@discussions.microsoft.com> wrote in message
news:7A**********************************@microsof t.com...
Hello,

I have a situation that I wish some help with. I have a DataSet object with DataTables populated from a ms access database. Each DataTable has a
RunLogTitle. I have a TreeView object with TreeNodes that correspods to the
Names of each DataTable's RunLogTitle. When the user clicks on a TreeNode
the corresponding DataTable shows up in the DataGrid.
This is working great, but I would want to use a DataView object to show only the components of each DataTable in the DataGrid. I am using a
DataGridTableStyle object to then create DataGridColumnStyles.
Here is the problem, in the DataGridTableStyle I have set the MappingName to a DataView object that I have created in the constructor, here is the
code that appears in the constructor of the class: this.myDataView = new DataView(new DataTable);
this.MyDataView.Table.TableName = "MyDataView";

When the form opens up, the DataGrid is populated with the appropriate DataView and the appropriate DataGridColumnStyles only showing the data I
wish to show up. HOwever when I click on a different TreeNode, I get an
error message stating that "MyDataView" already belongs to the DataSet.
I have been going nuts on trying to solve this, how can I set the DataView to show the other DataTale without getting this message? This is the best
way that I can describe this problem, if anyone out there can help me with
this I'll greatly appreicate it!
thanks,
ed

Nov 16 '05 #2
Thanks Branimir! I'll give this a try!

"Branimir Giurov" wrote:
Hi there,

what you need is not to set the table name every time, but simply assign the
new one to the dataGridTableStyle's mapping name right after setting the new
datasource.

dataGrid1.DataSource = new DataView(dataTable2, ....);
dataGridTableStyle1.MappingName = dataTable2.TableName;

This should work.

Good luck,
Branimir

--
Branimir Giurov
MCSD.NET, MCDBA
www.sofiadev.org

"Ed_P." <Ed*@discussions.microsoft.com> wrote in message
news:7A**********************************@microsof t.com...
Hello,

I have a situation that I wish some help with. I have a DataSet object

with DataTables populated from a ms access database. Each DataTable has a
RunLogTitle. I have a TreeView object with TreeNodes that correspods to the
Names of each DataTable's RunLogTitle. When the user clicks on a TreeNode
the corresponding DataTable shows up in the DataGrid.

This is working great, but I would want to use a DataView object to show

only the components of each DataTable in the DataGrid. I am using a
DataGridTableStyle object to then create DataGridColumnStyles.

Here is the problem, in the DataGridTableStyle I have set the MappingName

to a DataView object that I have created in the constructor, here is the
code that appears in the constructor of the class:
this.myDataView = new DataView(new DataTable);
this.MyDataView.Table.TableName = "MyDataView";

When the form opens up, the DataGrid is populated with the appropriate

DataView and the appropriate DataGridColumnStyles only showing the data I
wish to show up. HOwever when I click on a different TreeNode, I get an
error message stating that "MyDataView" already belongs to the DataSet.

I have been going nuts on trying to solve this, how can I set the DataView

to show the other DataTale without getting this message? This is the best
way that I can describe this problem, if anyone out there can help me with
this I'll greatly appreicate it!

thanks,
ed


Nov 16 '05 #3

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

Similar topics

9
by: Raymond Lewallen | last post by:
I have a dataview in which the sort property will not sort the dataview. Here's is a simple scenario similar to what I am doing: Class Foo Private Function Retrieve() As DataView ' Returns a...
4
by: Martin Schmid | last post by:
I am trying to implement a DataView for a DataGrid so I can sort at runtime by clicking on column headers. My initial page load works... it displays the data However, when I click a column...
6
by: Joe | last post by:
I have a DataView and would like to extract data from it and write it to a ListView. Can I only accomplish this with the DataViewRows Object array? Is there a way forme to enumerate through the...
3
by: Jonathan Allen | last post by:
What could cause a stack trace like this? Message:Object reference not set to an instance of an object. Stack Trace: at System.Data.DataView.GetRecord(Int32 recordIndex) at...
20
by: Mark | last post by:
Hi all, quick question , a DataView is memory resident "view" of data in a data table therefore once populated you can close the connection to the database. Garbage collection can then be used to...
36
by: kjvt | last post by:
Based on a prior posting, I've written a function to convert a recordset to a dataview. The first call to the function for a given recordset works perfectly, but the second call always returns a...
13
by: Steve | last post by:
I have a form with a dataset and a datagrid. I created a dataview on this dataset. When the user modifies the datagrid, I look up this record in the dataview to make sure it is unique. Here is...
14
by: Able | last post by:
Dear friends Dim myDataView as DataView = New DataView(dsData.Tables("tblCustomers")) myDataView.RowFilter = "City = 'London'" My question is how to loop through all rows in myDataView and...
10
by: Marc R. | last post by:
Hi all, I edit records using a form that have multiple control bind on Dataview, But I don't want to update right always to database, I would like to delay until all Changes (add all new...
4
by: James | last post by:
Basically I have a DataGrid that I'm binding to the results of a stored procedure call. The recordset is fairly small. Initially I'm creating a DataSet from the results and binding it. There's a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.