This is a migrated thread and some comments may be shown as answers.

updating the dataset from TextBox

1 Answer 103 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
HASSAN
Top achievements
Rank 1
HASSAN asked on 05 Jul 2011, 10:55 PM
i am new at this so it may be a stupid question !

I have a dataset in VB.NET 2010 , i am getting the dataset using FillBy method , providing one parameter , 
 Try
            Me.daNatalog.FillBy(Me.DsPatients.Patients, txtPatkey.Text)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
  End Try



i want to update the underlying data with any changed data in any of the bound controls. 

I am using one of the control as an example to understand this , its a radTextBox(txtEmail) whose databinding Text property is set to PatientBindingSource - email , DataSource Update mode is OnPropertyChanged 

i add this code to update dataset , this only update first character or give me some error

Private Sub txtEmail_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtEmail.TextChanged

        DsPatients.Tables(0).Rows(0)("e_mail") = txtEmail.Text.ToString
        daNatalog.Update(DsPatients.GetChanges())

    End Sub

This code does not do anything.

Private Sub txtEmail_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtEmail.Validated
        DsPatients.Tables(0).Rows(0)("e_mail") = txtEmail.Text.ToString
        daNatalog.Update(DsPatients.GetChanges())

    End Sub

Please let me know how would i get this working 

Thanks

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 08 Jul 2011, 11:23 AM
Hi Hassan,

You can try this solution to commit your changes to your DataTable object:

Private Sub txtEmail_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtEmail.TextChanged
 
    DsPatients.Tables(0).Rows(0)("e_mail") = txtEmail.Text.ToString
    Dim editableObject As IEditableObject = TryCast(DsPatients.Tables(0).Rows(0), IEditableObject)
    If editableObject IsNot Nothing Then
        editableObject.EndEdit()
    End If
    daNatalog.Update(DsPatients.GetChanges())
 
End Sub

Do not hesitate to contact us if you have further questions or issues.

Best wishes,
Julian Benkov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Buttons, RadioButton, CheckBox, etc
Asked by
HASSAN
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or