Databinding Postion

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Parveen

    #1

    Databinding Postion

    Hi,

    I am binding the controls on my form as follows:

    txtTextbox1.Dat aBindings.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.BindingConte xt(ds, "Table1").EndCu rrentEdit()
    Dim dr As DataRow = ds.Tables("Tabl e1").NewRow()
    dr.Item("mod_us er_name") = strUserID
    dr.Item("mod_da te_time") = Now
    ds.Tables("Tabl e1").Rows.Add(d r)
    Me.BindingConte xt(ds, "Table1").Posit ion = ds.Tables("Tabl e1").Rows.Cou nt
    - 1
    End Sub

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

    Does anyone know why this is happening?

    Thanks,
    Parveen


  • Parveen

    #2
    RE: Databinding Position

    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

    "Parveen" wrote:
    [color=blue]
    > Hi,
    >
    > I am binding the controls on my form as follows:
    >
    > txtTextbox1.Dat aBindings.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.BindingConte xt(ds, "Table1").EndCu rrentEdit()
    > Dim dr As DataRow = ds.Tables("Tabl e1").NewRow()
    > dr.Item("mod_us er_name") = strUserID
    > dr.Item("mod_da te_time") = Now
    > ds.Tables("Tabl e1").Rows.Add(d r)
    > Me.BindingConte xt(ds, "Table1").Posit ion = ds.Tables("Tabl e1").Rows.Cou nt
    > - 1
    > End Sub
    >
    > But for some reason, the value of Me.BindingConte xt(ds, "Table1").Posit ion
    > does not change. It remains set at 0 at all times.
    >
    > Does anyone know why this is happening?
    >
    > Thanks,
    > Parveen
    >
    >[/color]

    Comment

    Working...