Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Synchronizing data between datasources
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Synchronizing data between datasources
Versions des environnements
Environment:
C# 2.0
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01371933
Message ID:
01371933
Vues:
56
I have a business object for OfficeNotes. I created a grid named grdOfficeNotes which is set up as follows:
grdOfficeNotes.BindingSource: OfficeNote
grdOfficeNotes.BindingSourceMember: ONLocView

It is displayed on one page of a tab control.

On another page, I have a detail maintenance screen with the controls bound to the OfficeNote business object default table. I also changed one text box to reference the DefaultView to see if it was changing (BindingSourceMember: DefaultView.columnName).

Here's what I tried first:
        private void grdOfficeNotes_SelectionChanged(object sender, EventArgs e)
        {
            int currentPK = (int)grdOfficeNotes.GetCurrentRowPK();
            if (currentPK > 0)
            {
                oOfficeNote.GetCurrentDataSet().Tables["OfficeNote"].DefaultView.Sort = "OfficeNoteId";
                oOfficeNote.GetCurrentDataSet().Tables["OfficeNote"].DefaultView.Find(currentPK);
            }
        }
It gets the correct PK but didn't change the values on the detail page.


Based on notes in the help file under the topic "Synchronizing controls with different data sources", I made sure that the stored procedure put the rows in order by the OfficeNoteId and I modified the above code as follows, with no better result:
        private void grdOfficeNotes_SelectionChanged(object sender, EventArgs e)
        {
            int currentPK = (int)grdOfficeNotes.GetCurrentRowPK();
            string currentPKstr = currentPK.ToString();
            if (currentPK != 0)
            {
                oOfficeNote.GetCurrentDataSet().Tables["OfficeNote"].DefaultView.ApplyDefaultSort = true;
                int onPosition = oOfficeNote.GetCurrentDataSet().Tables["OfficeNote"].DefaultView.Find(currentPKstr);
                // Use the form's BindingContext object to set the position
                this.BindingContext[oOfficeNote.GetCurrentDataSet(), "OfficeNote"].Position = onPosition;
            }
        }
I don't want to just select a dataset that only contains the single row selected from the grid because there can be hundreds of notes for the currently selected patient. They use the grid to select one they're interested in but from there, they want to see all the notes that were entered around the same time. They will want to be able to hit next and previous to follow the thread of the notes. Ideally, I would prefer not to have to change the sort order for the detail page either but I'll live with that if I must.

Any ideas? Thanks.
Linda Harmes
HiBit Technologies, Inc.
Répondre
Fil
Voir

Click here to load this message in the networking platform