Databinding Postion

G

Guest

Hi,

I am binding the controls on my form as follows:

txtTextbox1.DataBindings.Add("Text", ds, "Table1.Field1")

I have a function called AddRow() then adds a new to the table and tries to
set the position of the binding context to the next new as follows:

Public Sub AddRow()
Me.BindingContext(ds, "Table1").EndCurrentEdit()
Dim dr As DataRow = ds.Tables("Table1").NewRow()
dr.Item("mod_user_name") = strUserID
dr.Item("mod_date_time") = Now
ds.Tables("Table1").Rows.Add(dr)
Me.BindingContext(ds, "Table1").Position = ds.Tables("Table1").Rows.Count
- 1
End Sub

But for some reason, the value of Me.BindingContext(ds, "Table1").Position
does not change. It remains set at 0 at all times.

Does anyone know why this is happening?

Thanks,
Parveen
 
G

Guest

Ok, I found the answer to my own question. The problem has to do with having
a DateTimePicker control on the form. Anytime this control is on the form
and new records are added to the data table, one has to make sure they
provide a default value for this control. Otherwise the binding context will
not set its position to the newly inserted record.

Hope this help others and they won't have to go through the pain that I had
to go through to figure this one out!

Parveen
 

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