Data bound listbox not updating...

  • Thread starter Thread starter Spock
  • Start date Start date
S

Spock

Hi. I have a form with a listbox and a few label fields all bound to a
dataset. When i navigate the listbox the labels change accordingly. so far
everything works good.

I made a button to delete a record. I delete the row from the datatable and
update the database with the adapter and that all works good. The record is
removed from the listbox.

Here is my problem.

I made another form to add a new record (has its own questions, input
fields, etc.). This form has its own connection, adapter and dataset
variables on it that it uses to add the new record. It works fine (adds the
new record to the actual database) but when I close that form and am now
back at the previous form (with the listbox), I cannot get the listbox to
update.

I've tried several suggestions from the web.

-re-filling the dataset (i.e. ds.clear() and then adapter.fill(ds,"table").
that did not work.

-Using the currencymanager's refresh() method from the dataset's
bindingcontext. That did not work.

-I've tried re-binding. as well as suspendbinding() and resumebinding().

I just don't understand it.

If I close that main form (the one with the listbox) and then go back into
it, it will now show the newly added record!! The form's startup has
nothing special that I didn't already try for refreshing it.

Any suggestions?

Thank you very much.


-Spock
 
Hello Spock,

Have you tried 'Unbinding' the listbox completely, then rebinding to the
dataset?
Also, if you are using 2 dataset instances (1 on each form) the dataset on
teh original form needs to be refilled. you might try using 1 instance of
the dataset and passing it between the forms.


hope that helps

Steve Stein
VB Team

This posting is provided "AS IS" with no warranties and confers no rights.

--------------------
| From: "Spock" <[email protected]>
| Subject: Data bound listbox not updating...
| Date: Thu, 20 Jan 2005 14:06:14 -0500
| Lines: 41
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: 69-163-11-6.kntnny.adelphia.net 69.163.11.6
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09
phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.languages.vb:254998
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| Hi. I have a form with a listbox and a few label fields all bound to a
| dataset. When i navigate the listbox the labels change accordingly. so
far
| everything works good.
|
| I made a button to delete a record. I delete the row from the datatable
and
| update the database with the adapter and that all works good. The record
is
| removed from the listbox.
|
| Here is my problem.
|
| I made another form to add a new record (has its own questions, input
| fields, etc.). This form has its own connection, adapter and dataset
| variables on it that it uses to add the new record. It works fine (adds
the
| new record to the actual database) but when I close that form and am now
| back at the previous form (with the listbox), I cannot get the listbox to
| update.
|
| I've tried several suggestions from the web.
|
| -re-filling the dataset (i.e. ds.clear() and then
adapter.fill(ds,"table").
| that did not work.
|
| -Using the currencymanager's refresh() method from the dataset's
| bindingcontext. That did not work.
|
| -I've tried re-binding. as well as suspendbinding() and resumebinding().
|
| I just don't understand it.
|
| If I close that main form (the one with the listbox) and then go back into
| it, it will now show the newly added record!! The form's startup has
| nothing special that I didn't already try for refreshing it.
|
| Any suggestions?
|
| Thank you very much.
|
|
| -Spock
|
|
|
 
Back
Top