need help to fill textboxes from a selected item in datagrid-selected index changed.

Discussion in '.NET' started by mldardy, Sep 28, 2010.

  1. mldardy

    mldardy

    Joined:
    Dec 9, 2008
    Messages:
    5
    I am trying to fill textboxes with the item I select in the datagrid but I keep getting the same record no matter what I select in the grid. I ham using a selected index changed event handler. here is my code behind for the event handler.

    Code:
     Protected Sub MHGrid_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MHGrid.SelectedIndexChanged
            Me.Table1.Visible = True
            Me.MHGrid.Visible = True
    
            Dim dvSql As DataView = DirectCast(MHFoundation.Select(DataSourceSelectArguments.Empty), DataView)
           
            Me.MHFoundation.SelectCommand = "SELECT POPULATION_LIST_ID, FIRST_NAME, MIDDLE_NAME, SSN, BIRTH_DATE, ADDRESS, SPOUSE_NAME, OTHER_ID2, WORK_PHONE, PREFERRED_COMMUNICATION, LAST_NAME, NAME_PREFIX, NAME_SUFFIX, MRN1, CITY, STATE, ZIP, CHILDREN,OTHER_ID1,POPULATION_TYPE,HOME_PHONE,CELL_PHONE,POPULATION_RATING,NOTES,EMAIL,PERSON_TYPE FROM CHP_POPULATION_LIST where POPULATION_LIST_ID = '" & ID.ToString() & "'"
    
    
    
    
            For Each drvSql As DataRowView In dvSql
                Me.lblPopulationID.Text = drvSql("POPULATION_LIST_ID").ToString
                Me.txtMRN.Text = drvSql("MRN1").ToString()
                Me.txtBirthDate.Text = drvSql("BIRTH_DATE").ToString()
                Me.txtPrefix.Text = drvSql("NAME_PREFIX").ToString()
                Me.txtFirstName.Text = drvSql("FIRST_NAME").ToString()
                Me.txtMiddleName.Text = drvSql("MIDDLE_NAME").ToString()
                Me.txtLastName.Text = drvSql("LAST_NAME").ToString()
                Me.txtSuffix.Text = drvSql("NAME_SUFFIX").ToString()
                Me.txtAddress.Text = drvSql("ADDRESS").ToString()
                Me.txtCity.Text = drvSql("CITY").ToString()
                Me.txtState.Text = drvSql("STATE").ToString()
                Me.txtZip.Text = drvSql("ZIP").ToString()
                Me.txtHomePhone.Text = drvSql("HOME_PHONE").ToString()
                Me.txtWorkPhone.Text = drvSql("WORK_PHONE").ToString()
                Me.txtCellPhone.Text = drvSql("CELL_PHONE").ToString()
                Me.txtEmail.Text = drvSql("EMAIL").ToString()
                Me.txtPreferred.Text = drvSql("PREFERRED_COMMUNICATION").ToString()
                Me.txtPerson.Text = drvSql("PERSON_TYPE").ToString()
                Me.txtOtherID1.Text = drvSql("OTHER_ID1").ToString()
                Me.txtOtherID2.Text = drvSql("OTHER_ID2").ToString()
                Me.txtSpouseName.Text = drvSql("SPOUSE_NAME").ToString()
                Me.txtChildren.Text = drvSql("CHILDREN").ToString()
                Me.txtNotes.Text = drvSql("NOTES").ToString()
            Next
    
        End Sub
     
    mldardy, Sep 28, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Julie Barnet
    Replies:
    0
    Views:
    2,316
    Julie Barnet
    Aug 20, 2003
  2. TN Bella
    Replies:
    1
    Views:
    2,478
    Edward
    Jun 18, 2004
  3. DCC700
    Replies:
    0
    Views:
    945
    DCC700
    Jul 14, 2006
  4. Santosh
    Replies:
    11
    Views:
    5,665
    Tim_Mac
    Sep 14, 2006
  5. Next
    Replies:
    0
    Views:
    126
Loading...

Share This Page