Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / October 2005

Tip: Looking for answers? Try searching our database.

binding to the DataGridView

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tony - 15 Oct 2005 13:26 GMT
I've been looking at the code samples for binding data to a DataGridView
using the bindingSource property.

I do somthing like

bindingSource = new BindingSource();
dataGridView.DataSource = bindingSource;
Refresh();

private void Refresh()
{
 DataTable t = GetDataTable( mySQLStmt );
 bindingSource.DataSource = t;
}

My problem is that the binding only points the DataGridView to an instance
of the data when the Refresh( ) is performed. After the refresh is performed
the binding is broken.  If the data in my database changes I have to call
refresh again. This is relatively slow.  There isn't a permanent binding
between the grid and the data. It’s more like the grid shows a snapshot in
time.  

I want to display a grid and then allow data in that grid to be changed
through some edit controls in the UI (or even changing the cells in the
grid), however this mechanism isn’t really binding the grid to the database
all its doing is saying at some instance in time manually update the grid.

In VB6 I used to use a datacontrol, bind the grid to the datacontrol, If I
changed the underlying data through an edit control bound to the datasource
the grid would update instantaneously, I didn’t need to perform a refresh the
grid was permanently bound to my data and reflected whatever happened to my
data.

Is this possible in .NET 2.0?

TIA
Bart Mermuys - 16 Oct 2005 14:04 GMT
Hi,

> I've been looking at the code samples for binding data to a DataGridView
> using the bindingSource property.
[quoted text clipped - 19 lines]
> between the grid and the data. It's more like the grid shows a snapshot in
> time.

DB <-> DataTable <-> DataGridView

There is a permanent binding between the DataTable and the DataGridView but
there is no permanent binding between the DataTable and the DB, because
ADO.NET uses a disconnected model.

If a TextBox is bound to the same DataTable as a DataGridView and you change
the TextBox then the DataTable will change and also the DataGridView, but
not the DB. The DB will only be updated when you use DataAdapter.Update.

If it possible you should prefer this way, because it's more scalable.

If you really want a connected model then as far as i know there is little
(or even no) support for this in ADO.NET, do a google search on "+ADO.NET
+connected" or re-ask your question in
"microsoft.public.dotnet.framework.adonet".

HTH,
Greetingss

> I want to display a grid and then allow data in that grid to be changed
> through some edit controls in the UI (or even changing the cells in the
[quoted text clipped - 14 lines]
>
> TIA

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.