473,831 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 DataGridTableSt yle object to then create DataGridColumnS tyles.

Here is the problem, in the DataGridTableSt yle 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.TableNam e = "MyDataView ";

When the form opens up, the DataGrid is populated with the appropriate DataView and the appropriate DataGridColumnS tyles 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 2483
Hi there,

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

dataGrid1.DataS ource = new DataView(dataTa ble2, ....);
dataGridTableSt yle1.MappingNam e = dataTable2.Tabl eName;

This should work.

Good luck,
Branimir

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

"Ed_P." <Ed*@discussion s.microsoft.com > wrote in message
news:7A******** *************** ***********@mic rosoft.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
DataGridTableSt yle object to then create DataGridColumnS tyles.
Here is the problem, in the DataGridTableSt yle 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.TableNam e = "MyDataView ";

When the form opens up, the DataGrid is populated with the appropriate DataView and the appropriate DataGridColumnS tyles 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 dataGridTableSt yle's mapping name right after setting the new
datasource.

dataGrid1.DataS ource = new DataView(dataTa ble2, ....);
dataGridTableSt yle1.MappingNam e = dataTable2.Tabl eName;

This should work.

Good luck,
Branimir

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

"Ed_P." <Ed*@discussion s.microsoft.com > wrote in message
news:7A******** *************** ***********@mic rosoft.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
DataGridTableSt yle object to then create DataGridColumnS tyles.

Here is the problem, in the DataGridTableSt yle 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.TableNam e = "MyDataView ";

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

DataView and the appropriate DataGridColumnS tyles 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
2104
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 DataView with 2 columns and 3 rows Dim ADOHelper As New DAL.ADOHelper Return ADOHelper.GetMyDataview() End
4
1543
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 heading at run time, the data doesn't sort as expected, in fact, the DataGrid becomes empty, all I see are column headings: SqlConnection sqlConnection; protected System.Web.UI.WebControls.DataGrid DataGrid1; protected ProjContMan.dsProjByDate...
6
10431
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 rows of the DataView without using the DataViewRows array? TIA, -- Joe
3
3432
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 System.Data.DataView.get_RowViewCache() at System.Data.DataView.GetElement(Int32 index) at System.Data.DataView.get_Item(Int32 recordIndex) at myCode.myMethod
20
5541
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 "clean up" the DataView once it is not referenced and will not effect the number of connections to the database. A DataReader on the other hand always maintains a connection to the database and must be explicitly closed (Do not rely on garbage...
36
4486
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 dataview with a count = 0. Can someone explain why and how I might work around this problem? Here is the code for my function: Public Shared Function GetViewFromRS(ByVal pRS As ADODB.Recordset) _ As DataView
13
2121
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 the confusion......... I thought that the DataView is the view from the dataset, but it seems that the dataview has the records that are in the datagrid, because everytime I search for a record that I know is NOT in the dataset, it finds it. I...
14
9883
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 edit the field fldZipCode so fldZipCode = "9800" Regards Able
10
1962
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 record using a form or edit various existing records) This way I could minimize transaction on server..
4
1587
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 DropDownList on my page that filters the records that are displayed in the grid. How I'm currently handling this is when I initially bind, I create a DataView from the table in the dataset. When the DropDownList changes selection, I get the...
0
9794
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10778
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10496
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9319
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5622
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.