473,407 Members | 2,320 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,407 software developers and data experts.

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 1916
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******************@twister.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******************@twister.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******************@twister.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*****@cherwellinc.com> wrote in message
news:ur****************@TK2MSFTNGP10.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******************@twister.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*****************@twister.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*****@cherwellinc.com> wrote in message
news:ur****************@TK2MSFTNGP10.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******************@twister.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
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...
3
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...
2
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...
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...
8
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 =...
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...
5
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...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
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...
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
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,...
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.