|
I am working on a smart client Winforms application (C#) modelled on TaskVision. I have have one combo box (Projects) and several text boxes (demographic data). I am binding the text boxes to the dataset (DsPersons). When selecting a project in the combobox, the relevant (matching) dataset is retrieved. In TaskVision, a datagrid is populated with data related to the Combobox selection. I am adapting this to populate textboxes.
When in offline mode, all the Person' information is stored in one xml file regardless of the project. This file holds the ID the projects matching the options selectable in the Projects combobox. Therefore in offline mode I am needing to filter the dataset to bind only the filtered subset to the controls based on the project selection.
Below is more detail of my problem. Hopefully someone can assist.
I can databind and I can cycle through records. However all records are displayed rather than just those related to the Project displayed in the combo box.
How do apply a filter where databinding has been utililised?
My binding code is below: ----------------------------------------------------------- txtFirstName.DataBindings.Add("Text",m_DataLayer.DsPerson, "Person.FirstName"); txtsurname.DataBindings.Add ("Text",m_DataLayer.DsPerson, "Person.Surname"); txtTelH.DataBindings.Add ("Text",m_DataLayer.DsPerson,"Person.Email"); //Get a reference to the BindingManagerBase for the Person table. bm = BindingContext[m_DataLayer.DsPerson, "Person"]; drvPerson =(DataRowView)bm.Current;
----------------------------------------------------------- I have tried to use the below code which would satisfy a filter for a datagrid: m_DataLayer.DSPerson.Person.DefaultView.RowFilter = "ProjectID =" + m_ProjectID; This has no effect.
I have tried binding to a dataview which permitted the control databinding but an error is thrown ("Cannot create Child list for field Person") at the point of setting binding context to the datview. If one leaves the Binding context to the dataset then the controls are bound to the dataview and the binding context to the dataset and therefore the datataset cycles but not the dataview when the "Next" navigation button is selectd to cycle through records (using the code bm.Position += 1).
Is it possible to achieve binding to a filitered dataset when using binding?
Thanks in advance.
Grant
|