Step 1: Simple textbox text change on dropdown value change.
- protected void ddlProducts_SelectedIndexChanged(object sender, EventArgs e)
- {
-
- txtName.Text = "change value here";
-
- }
Step 2: If textbox is inside any data control.
- protected void ddlProducts_SelectedIndexChanged(object sender, EventArgs e)
- {
- DropDownList ddl = (DropDownList)sender;
- GridViewRow row = (GridViewRow)ddl.NamingContainer;
- TextBox txtName = (TextBox)row.FindControl("txtCp");
- txtName.Text = "*****";
-
- }
Step 3: If textbox is inside parent control.
- protected void ddlProducts_SelectedIndexChanged(object sender, EventArgs e)
- {
- DropDownList drop = sender as DropDownList;
- TextBox txt_box = drop.Parent.FindControl("TextBox1") as TextBox;
- if (txt_box != null)
- txt_box.Text = drop.SelectedValue; }