Databinding

D

DLI

Scenario:

I have a form and two text boxes and one datagrid.

I have a dataset composed of two tables
Questions (QuestionID, QuestionText)
Answers (QuestionID, AnswerText)

there is a one to many relationship between Questions and Answers defined by
this Relation (QuestionAnswer) in the dataset ds

txtQuestionID is bound to a Questions.QuestionID
txtQuestion is bound to a Questions.QuestionText
this.txtQuestion.DataBindings.Add("Text", ds.Tables["Questions"],
"QuestionText");

this.txtQuestionID.DataBindings.Add("Text", ds.Tables["Questions"],
"QuestionID");



Datagrid named dgAnswers is bound to the relation QuestionAnswer

I have a move next button and a move previous button that sets the position
of the table questions forward and back.

The question and the txtQuestionID and txtQuestion change as they should
when I click the buttons.

Problem:
The datagrid displays the list of possible answers for the first question
only (correctly) when the form opens
When I click the next button, the text boxes both change but the datagrid
stays with the answers for the first question.


I have tried very syntax I can think of like:
this.dgAnswers.BindingContext = this.BindingContext;

this.dgAnswers.SetDataBinding(ds, "Questions.QuestionAnswer");

If I place another datagrid on the form and set its datasource to

this.dgQuestions.SetDataBinding(ds, "Questions");

and click a different question in this grid, the selection updates properly
in dgAnswers

How can I get the controls and the datagrid to use the same CurrencyManager?
 
D

DLI

Never Mind,

I needed to use a DataViewManager object in order to synchronize all of the
controls on the form.

I wish this was a little more prominent in SOME documentation SOMEWHERE

As soon as I switched to this object, everything works as I had anticipated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top