Simple text box binding problem

G

Guest

Hi,

I have a very simple problem. I have a drop down list which is bound to a
data command on page load. Now when the user selects a value from the drop
down list, another text box should be filled with the "Account No." from the
database for that Customer. But this is not happening...when i select a value
in the drop down, the text box doesnt display anything.

I think something is wrong with my code which is as follows::

private void ddlCustomer_SelectedIndexChanged(object sender,
System.EventArgs e)
{
sqlCommand2.Parameters["@vv"].Value=ddlCustomer.SelectedValue;
sqlConnection2.Open();
dr2=sqlCommand2.ExecuteReader();

dr2.Read();
txtAccount.DataBind();
txtAccount.Text= dr2.GetValue(0).ToString();

sqlConnection2.Close();
}

Any help is appreciated..
Thanks
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top