I have one dropdown list and two textbox.
i am developing a small application for my par tics in which currency name populate from the data base which are in drop down it will working now.
Now I want when I select currency name from dropdown list the code the and the country name show in the other textbox value .for example when I select Currency name like UK pound the value show .one show currency code 2 and other country name United state. All text box value change on changing vale in droupdownlist dynamically means all value dependent on the dropdown list .
All value from the data base
I bind three value with the currency name ,id,currency code and country name. because when I change the dropdown list so change value in text box .but I fail to do that.
Please help me how value change in textbox to changing value in dropdown list. I know code show be on the DropDownList1_SelectedIndexChanged but I have no exact code
My data base.table
Id (primary key) Currency Name Curreny code countyname
1 Bangla Taka 3 Bangldash
2 Chines Yan 5 China
Code
private String strConnection = "Data Source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|Database1.mdf;User Instance=true";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindCurrencydropdown();
}
}
protected void BindCurrencydropdown()
{
//conenction path for database
SqlConnection con = new SqlConnection(strConnection);
con.Open();
SqlCommand cmd = new SqlCommand("select * from Table1", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "CurrencyName";
DropDownList1.DataValueField = "ID";
DropDownList1.DataValueField = "CurrencyCode";
DropDownList1.DataValueField = "CountryName";
DropDownList1.DataBind();
DropDownList1.Items.Insert(0, new ListItem("--Select--", "0"));
DropDownList1.SelectedIndex = 0;
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
If DropDownList1.seleceteditem.ToString()
{
TextBox1.Text =””;
TextBox2.Text
}
}
}
please help me to solve it