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 General / January 2007

Tip: Looking for answers? Try searching our database.

Refresh databinding?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jakob Lithner - 25 Jan 2007 12:54 GMT
I have a form where I want to populate a grid wih a dataset table.

To get the convenient designtime help I have dragged a typed dataset onto
the form, thus receiving a dataset control and a bindingsource control on the
fly.

As the dataset is quite heavy I want to reuse an existing dataset of the
main form, already loaded with data. The dataset is sent to the subform
constructor as a reference.

Problem is that when I change datasource of the grid I loose specific
formatting, set through the designer bindingsource.

My idea then was to try switching the datasource of the bindingsource
control. This seems to partly work. The bindingsource reports to have the
correct number of records. BUT they still don't show up in the grid!

Me.TblFeedbackBindingSource.DataSource = _ds

I expected some kind of refresh mechanism, but the data is not shown until I
add this line, where I specify the datasource of the grid ONCE AGAIN. Why is
this necessary to do again?
grdFeedback.DataSource = Me.TblFeedbackBindingSource
RobinS - 25 Jan 2007 21:57 GMT
What do you mean, when you change the data source of the grid? Is it
just
the one statement you've given?

One thing is if that is a dataset, you need to specify which table in
the
dataset the binding source should use, like this:

 TblFeedbackBindingSource.DataSource = _ds.Tables("Customers")

If it's strongly typed, you can access the table name directly,
something
like this:

 TblFeedbackBindingSource.DataSource = _ds.CustomerTable

HTH.
Robin S.
--------------------------------------------------------------------

>I have a form where I want to populate a grid wih a dataset table.
>
[quoted text clipped - 26 lines]
> this necessary to do again?
> grdFeedback.DataSource = Me.TblFeedbackBindingSource
Linda Liu [MSFT] - 26 Jan 2007 03:51 GMT
Hi Jakob,

I performed a test based on your description but could not reproduce your
problem.

When the DataSource or DataMember property of a BindingSource component is
changed, and the BindingSource component has been set as the data source of
a DataGridView,  data binding will update the data in the DataGridView
automatically and we needn't set the DataSource property of the
DataGridView control once again.

Note that if you change the DataSource property of the BindingSource
component, to get the data displayed correctly in the DataGridView control,
you should ensure that the new dataset instance has a DataTable with the
same name and schema as the previous dataset instance does.

Beside the above possibility, I think other possible reasons of your
problem may be that the DataSource property of your DataGridView control
has been changed somewhere else or the the BindingSource component whose
DataSource property you changed is not the one that the DataGridView
control is bound to.

If the problem is not still solved, you may send me your sample project
that could just reproduce the problem. To get my actual email address,
remove 'online' from my displayed email address.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Ciaran O''Donnell - 26 Jan 2007 12:57 GMT
If the dataset has exactly the same schema but the refresh doesnt happen
automatically, call:

TblFeedbackBindingSource.ResetBindings(false)

Signature

Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com

> I have a form where I want to populate a grid wih a dataset table.
>
[quoted text clipped - 19 lines]
> this necessary to do again?
> grdFeedback.DataSource = Me.TblFeedbackBindingSource
Jakob Lithner - 29 Jan 2007 15:43 GMT
My own fault!

Today I detected an event handler that had a line of code setting the grid
datasource to nothing, which of course explains all ..... !

Sorry about that.

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.