updating the dataset from TextBox

2 posts, 0 answers
  1. HASSAN
    HASSAN avatar
    2 posts
    Member since:
    Apr 2011

    Posted 05 Jul 2011 Link to this post

    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
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 08 Jul 2011 Link to this post

    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!

  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top