Binding Manager Position not changing

  • Thread starter Kunjal Karamshi
  • Start date
K

Kunjal Karamshi

I have a peculiar problem. I have a dataset with two
records in it. When I am positioned at the first record
and try to navigate to the second on a form which uses
data binding, the binding manager position does not
change. Any ideas as to what could be happening? Has
anyone else come across this? I will add that if I bind
the same dataset to a datagrid, both records show up
without any exceptions being thrown.

Here is the code for the event handler that I'm using:

private void btnNext_Click(object sender, System.EventArgs
e)
{
BindingManagerBase bmb;
bmb = (BindingManagerBase) this.BindingContext
[dsPolicies,"Table"];
bmb.Position += 1;
UpdateDisplay();
}

private void UpdateDisplay()
{
BindingManagerBase bmb;
bmb = (BindingManagerBase) this.BindingContext
[dsPolicies,"Table"];

this.txtPosition.Text = (bmb.Position + 1).ToString();
this.txtPosition.Text += " of ";
this.txtPosition.Text += bmb.Count.ToString();
}

The Locals window shows that that the dataset has 2
records, the BindingManagerBase has a count of 2 and a
position of 0 which does not seem to change at all.

I hope someone out there can tell me what is going on!
 
M

Miha Markic

Hi Kunjal,

You are probably getting the wrong bindingmanagerbase.
Try this:
bmb = (BindingManagerBase) this.BindingContext [dsPolicies.Tables["Table"]];

BTW, how do you bind table?
 

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