By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,109 Members | 993 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,109 IT Pros & Developers. It's quick & easy.

DataTable, BindingSource and DataGridView

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
"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.