kumartyr

kumartyr

  • NA
  • 55
  • 28k

How to autopopulate a textbx with data keyed in other txtbox

Jul 9 2013 2:17 AM
i have two textbox in a form and will be typing firstname and lastname in that two textbox

what i want is if i type a name in first textbox and do tab or mouseclick to next textbox i want the matching lastname of the firstname
to be automatically populated

how to do this... i have written the below coding but am not able to find which textbox event will be appropriate to do this..
please someone clarify my doubt

if (LastNameTextBox.Text == "")
{
ACSCLN = new AutoCompleteStringCollection();
ORCMND13 = new OracleCommand("Select LASTNAME from VMS_VISITOR where FIRSTNAME='" + FirstNameTextBox.Text + "'", CON);
DR22 = ORCMND13.ExecuteReader();

if (DR22.HasRows == true)
{
while (DR22.Read())
{
ACSCLN.Add(DR22["LASTNAME"].ToString());
}

LastNameTextBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
LastNameTextBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
LastNameTextBox.AutoCompleteCustomSource = ACSCLN;

}
LastNameTextBox.Focus();

Answers (2)