473,789 Members | 2,679 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataView - How to access the row in the datatable behind the DataView

Windows Forms, csharp, 20 rows in DataTable 14 shown in view after filter
applied. For any of the 14 how do I do the datarow or something else thing
to access the data in the row of the table behind the view selected on the
datagrid.

DataGrid only gives an index based on the 1-14 visible on the datagrid and I
can't seem to update anything I see in the dataview quickwatch that I can
update the underlying row. I could manually keep track of the index to the
datatable but if I could figure out how to update the table behind the
dataGrid index of the view without a lot of looping, comparing, etc.
Nov 17 '05 #1
5 1934
I'm not sure I understand the question completely, but would using a DataSet
work for this?
Put the DataTables in a DataSet and then make the DataSet the source for the
DataGrid.

"Richard" <a@b.com> wrote in message
news:NF******** **********@twis ter.nyc.rr.com. ..
Windows Forms, csharp, 20 rows in DataTable 14 shown in view after filter
applied. For any of the 14 how do I do the datarow or something else thing
to access the data in the row of the table behind the view selected on the
datagrid.

DataGrid only gives an index based on the 1-14 visible on the datagrid and
I
can't seem to update anything I see in the dataview quickwatch that I can
update the underlying row. I could manually keep track of the index to the
datatable but if I could figure out how to update the table behind the
dataGrid index of the view without a lot of looping, comparing, etc.

Nov 17 '05 #2
Richard,
I'm not following what you want?

A DataView is a "live" view into a DataTable.

Updating a row in a DataView updates the corresponding row in the DataTable.
As you know DataTable contains a collection of DataRow objects. The DataView
itself contains a collection of DataRowView objects. DataRowView has a Row
property that is the DataRow itself in the DataTable.

You really shouldn't need to track any indexes, as that is the DataView's
job.

Hope this helps
Jay

"Richard" <a@b.com> wrote in message
news:NF******** **********@twis ter.nyc.rr.com. ..
| Windows Forms, csharp, 20 rows in DataTable 14 shown in view after filter
| applied. For any of the 14 how do I do the datarow or something else thing
| to access the data in the row of the table behind the view selected on the
| datagrid.
|
| DataGrid only gives an index based on the 1-14 visible on the datagrid and
I
| can't seem to update anything I see in the dataview quickwatch that I can
| update the underlying row. I could manually keep track of the index to the
| datatable but if I could figure out how to update the table behind the
| dataGrid index of the view without a lot of looping, comparing, etc.
|
|
Nov 17 '05 #3
Hi Richard,

This isn't difficult. When you do a .find on a dataview, it returns the row
index. The following syntax enables you to update that very row, without
looping of any kind:
If ifind <> -1 Then ' ie, found it

dsprod.Tables(0 ).Rows(ifind)(" copywt") = "abcd"

dsprod.Tables(0 ).Rows(ifind)(" onsaledt") = CDate("05/10/2003")

End If

HTH,

Bernie Yaeger

"Richard" <a@b.com> wrote in message
news:NF******** **********@twis ter.nyc.rr.com. ..
Windows Forms, csharp, 20 rows in DataTable 14 shown in view after filter
applied. For any of the 14 how do I do the datarow or something else thing
to access the data in the row of the table behind the view selected on the
datagrid.

DataGrid only gives an index based on the 1-14 visible on the datagrid and
I
can't seem to update anything I see in the dataview quickwatch that I can
update the underlying row. I could manually keep track of the index to the
datatable but if I could figure out how to update the table behind the
dataGrid index of the view without a lot of looping, comparing, etc.

Nov 17 '05 #4
Now that I learned the current row index of the data grid corresponds to the
DataRowView's copy of the bound data table's record, I think I can refine it
with the copywt code below. I use a single table which is not in a dataset
but I think it will still work.

"Bernie Yaeger" <be*****@cherwe llinc.com> wrote in message
news:ur******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi Richard,

This isn't difficult. When you do a .find on a dataview, it returns the row index. The following syntax enables you to update that very row, without
looping of any kind:
If ifind <> -1 Then ' ie, found it

dsprod.Tables(0 ).Rows(ifind)(" copywt") = "abcd"

dsprod.Tables(0 ).Rows(ifind)(" onsaledt") = CDate("05/10/2003")

End If

HTH,

Bernie Yaeger

"Richard" <a@b.com> wrote in message
news:NF******** **********@twis ter.nyc.rr.com. ..
Windows Forms, csharp, 20 rows in DataTable 14 shown in view after filter applied. For any of the 14 how do I do the datarow or something else thing to access the data in the row of the table behind the view selected on the datagrid.

DataGrid only gives an index based on the 1-14 visible on the datagrid and I
can't seem to update anything I see in the dataview quickwatch that I can update the underlying row. I could manually keep track of the index to the datatable but if I could figure out how to update the table behind the
dataGrid index of the view without a lot of looping, comparing, etc.


Nov 17 '05 #5
Hi Richard,

Yes, it should, but if you have any questions, send me some code and I'll be
glad to look at it.

Bernie

"Richard" <a@b.com> wrote in message
news:zu******** *********@twist er.nyc.rr.com.. .
Now that I learned the current row index of the data grid corresponds to
the
DataRowView's copy of the bound data table's record, I think I can refine
it
with the copywt code below. I use a single table which is not in a dataset
but I think it will still work.

"Bernie Yaeger" <be*****@cherwe llinc.com> wrote in message
news:ur******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi Richard,

This isn't difficult. When you do a .find on a dataview, it returns the

row
index. The following syntax enables you to update that very row, without
looping of any kind:
If ifind <> -1 Then ' ie, found it

dsprod.Tables(0 ).Rows(ifind)(" copywt") = "abcd"

dsprod.Tables(0 ).Rows(ifind)(" onsaledt") = CDate("05/10/2003")

End If

HTH,

Bernie Yaeger

"Richard" <a@b.com> wrote in message
news:NF******** **********@twis ter.nyc.rr.com. ..
> Windows Forms, csharp, 20 rows in DataTable 14 shown in view after filter > applied. For any of the 14 how do I do the datarow or something else thing > to access the data in the row of the table behind the view selected on the > datagrid.
>
> DataGrid only gives an index based on the 1-14 visible on the datagrid and > I
> can't seem to update anything I see in the dataview quickwatch that I can > update the underlying row. I could manually keep track of the index to the > datatable but if I could figure out how to update the table behind the
> dataGrid index of the view without a lot of looping, comparing, etc.
>
>



Nov 17 '05 #6

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

Similar topics

9
2589
by: jwedel_stolo | last post by:
Hi I'm creating a dataview "on the fly" in order to sort some data prior to writing out the information to a MS SQL table I have used two methods in order to determine the sort order of the DataView. (I'm writing in C# with the v1.1.4322 of the .NET Framework, in Window2K server"). First of all, here are the two methods I have used in order to apply the sorting property to the DataView 1. Simply defining the sort order and colum DataView...
3
9811
by: Brian Bischof | last post by:
I'm using a third-party tool that takes a DataTable as a parameter. I really need to pass it a DataView instead. When I try to explicitly cast the DataView as a DataTable I get an error that they aren't compatible data types. Does anyone have a suggestion on how to do this? My last resort is to create a new DataTable object and copy the rows from the DataView into the DataTable. But this is an ugly hack and I really hope there is a...
2
2478
by: Ed_P. | last post by:
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...
20
5537
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...
8
3900
by: Dave Hagerich | last post by:
I'm using a DataGrid with a DataSet and I'm trying to filter the data being displayed, using the following code as a test: DataView theView = new DataView(theDataSet.Tables); theView.RowFilter = "'Record ID' = '0'"; theView.RowStateFilter = DataViewRowState.ModifiedCurrent; Debug.WriteLine(string.Format("RowFilter = {0}", theView.RowFilter)); RecordDataGrid.DataSource = theView; RecordDataGrid.DataBind();
36
4484
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
5
8005
by: Richard | last post by:
Windows Forms, csharp, 20 rows in DataTable 14 shown in view after filter applied. For any of the 14 how do I do the datarow or something else thing to access the data in the row of the table behind the view selected on the datagrid. DataGrid only gives an index based on the 1-14 visible on the datagrid and I can't seem to update anything I see in the dataview quickwatch that I can update the underlying row. I could manually keep track...
0
9666
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
9511
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
10408
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
10199
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...
1
10139
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9020
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...
1
7529
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5417
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...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.