473,837 Members | 1,931 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 1936
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
2592
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
9816
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
2484
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
5542
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
3906
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
4487
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
8007
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
9843
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
9682
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,...
1
10626
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
9402
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
7806
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
5849
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4474
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
4041
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3124
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.