469,927 Members | 1,904 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

DataTable, BindingSource and DataGridView

I could use a little clarification on using a BindingSource with my
DataTable. As I understand it, the BindingSource sits between my data source
(a DataTable) and DataGridView and any changes made to it is reflected in
the other two?

Now if that is so, how should I access the elements of my DataTable? I need
to make decisions on what Rows to remove based on comparing the values of
the elements. Should I access the individual elements via the DataTable,
DataGridView cell values, or am I missing a member in my BindingSource
object that allows me to retrieve and/or modify individual element values?

TIA

Eric B.

Nov 18 '08 #1
2 16530
Eric,

The BindingSource class was introduced because people were used to
having the notion of a "current" record combined ^with^ the data set.

You can access the current values of the "row" in the BindingSource
through the indexer (the same way you would with a DataRow).

If you need to cycle through the rows, you can use the MoveFirst,
MoveNext, MoveLast, MovePrevious methods to navigate through the data.

If the possibility of the type of the underlying data source might
change, from a design standpoint, it would be better to work with the
BindingSource, since that is abstracting the underlying data type.

However, if the underlying data source type is "baked", meaning it will
not change, then work with the data set.

I will typically construct my own DataView when working with a DataTable
and I need to perform specific sorting or filtering. If I don't have a need
for that, then I access the DataSet directly.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Eric B." <bi*****@sesamestreet.comwrote in message
news:E9**********************************@microsof t.com...
>I could use a little clarification on using a BindingSource with my
DataTable. As I understand it, the BindingSource sits between my data
source (a DataTable) and DataGridView and any changes made to it is
reflected in the other two?

Now if that is so, how should I access the elements of my DataTable? I
need to make decisions on what Rows to remove based on comparing the
values of the elements. Should I access the individual elements via the
DataTable, DataGridView cell values, or am I missing a member in my
BindingSource object that allows me to retrieve and/or modify individual
element values?

TIA

Eric B.
Nov 19 '08 #2
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:9B**********************************@microsof t.com...
Eric,

The BindingSource class was introduced because people were used to
having the notion of a "current" record combined ^with^ the data set.

You can access the current values of the "row" in the BindingSource
through the indexer (the same way you would with a DataRow).

If you need to cycle through the rows, you can use the MoveFirst,
MoveNext, MoveLast, MovePrevious methods to navigate through the data.

If the possibility of the type of the underlying data source might
change, from a design standpoint, it would be better to work with the
BindingSource, since that is abstracting the underlying data type.

However, if the underlying data source type is "baked", meaning it will
not change, then work with the data set.

I will typically construct my own DataView when working with a
DataTable and I need to perform specific sorting or filtering. If I don't
have a need for that, then I access the DataSet directly.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Eric B." <bi*****@sesamestreet.comwrote in message
news:E9**********************************@microsof t.com...
>>I could use a little clarification on using a BindingSource with my
DataTable. As I understand it, the BindingSource sits between my data
source (a DataTable) and DataGridView and any changes made to it is
reflected in the other two?

Now if that is so, how should I access the elements of my DataTable? I
need to make decisions on what Rows to remove based on comparing the
values of the elements. Should I access the individual elements via the
DataTable, DataGridView cell values, or am I missing a member in my
BindingSource object that allows me to retrieve and/or modify individual
element values?

TIA

Eric B.
Thank you very much for the explanation. :D

Eric B.

Nov 20 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Irfan | last post: by
1 post views Thread by sapkal.manish | last post: by
4 posts views Thread by Christian | last post: by
reply views Thread by myotheraccount | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.