---
title: "Populate text boxes on dropdownlist select in asp.net"  
description: "Populate text boxes on dropdownlist select in asp.net"  
author: "Anonymous User"  
published: 2014-12-08  
updated: 2014-12-08  
canonical: https://www.mindstick.com/forum/12762/populate-text-boxes-on-dropdownlist-select-in-asp-dot-net  
category: "asp.net"  
tags: ["c#", "dropdown"]  
reading_time: 2 minutes  

---

# Populate text boxes on dropdownlist select in asp.net

I am new at asp.net. I have a [dropdownlist](https://www.mindstick.com/articles/324837/how-to-bind-dropdownlist-in-mvc-core-from-database-using-entity-framework) which is populated in [code behind](https://www.mindstick.com/forum/2199/call-javascript-s-function-from-code-behind). When I select any item from dropdownlist, it should [populate](https://www.mindstick.com/blog/60/populate-records-in-second-listbox-according-to-the-selection-in-first-list-box) two [textbox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) and another dropdownlist according to data from table.

```
<asp:DropDownList runat="server" ID="dropDownExisting"></DropDownList><br /><asp:TextBox ID="txtPromotion" runat="server" Width="77px" ></asp:TextBox><br /><asp:TextBox ID="txtSubject" runat="server" Width="288px"></asp:TextBox><br /><asp:DropDownList ID="dropDownType" runat="server">    <asp:ListItem>Monthly Newsleter</asp:ListItem>    <asp:ListItem>Webbinar Newsleter</asp:ListItem>    <asp:ListItem>Annoucement</asp:ListItem></asp:DropDownList>
```

I want it to be done on [client side](https://www.mindstick.com/forum/160418/what-are-the-best-practices-for-securely-storing-bearer-tokens-on-the-client-side). Where do I have to provide [database connectivity](https://www.mindstick.com/blog/462/database-connectivity-in-c-sharp)? Do I require to use ajax [control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control) like [update panel](https://www.mindstick.com/forum/418/is-it-possible-to-use-fileupload-control-within-the-update-panel)? Or [javascript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript) will work well? I want it on client side.

## Replies

### Reply by Allen Scott

Simply you can do this in DropDown SelectedIndexChanged Event

SelectedIndexChanged

**Edit**

```
<asp:UpdatePanel ID="upDdlGoal" runat="server" UpdateMode="always">   
<ContentTemplate>     
<asp:DropDownList ID="drop1" runat="server" AutoPostBack="true" EnableViewState="true"
OnSelectedIndexChanged="drop1_SelectedIndexChanged">                    </asp:DropDownList>   
</ContentTemplate>    <Triggers>       
<asp:AsyncPostbackTrigger ControlID="drop1" EventName="SelectedIndexChanged" />      </Triggers></asp:UpdatePanel>
```

**Code Behind:**

**C#:**

```
protected void drop1_SelectedIndexChanged(object sender, System.EventArgs e){    //Connectivity coding}
```

### Reply by Anonymous User

Clients ide coding using JavaScript

## .aspx

```
  <asp:DropDownList runat="server" ID="dropDownExisting" ></asp:DropDownList><br
/>    <asp:TextBox ID="txtPromotion" runat="server" Width="77px"></asp:TextBox><br />    <asp:TextBox ID="txtSubject" runat="server" Width="288px"></asp:TextBox><br />   
<asp:DropDownList ID="dropDownType"runat="server">        <asp:ListItem>Monthly Newsleter</asp:ListItem>       
<asp:ListItem>Webbinar Newsleter</asp:ListItem>       
<asp:ListItem>Annoucement</asp:ListItem>   
</asp:DropDownList>
```

## .cs

```
  protected void Page_Load(object sender, EventArgs e)        {             dropDownType.Attributes.Add("onChange","return OnSelectedIndexChange();");        }JavaScript:    <script type="text/javascript">          function OnSelectedIndexChange() {              var sel= document.getElementById("dropDownExisting");              var text= sel.options.value;              var out= document.getElementById("txtPromotion");             
out.value += text + "\n";          }</script>
```


---

Original Source: https://www.mindstick.com/forum/12762/populate-text-boxes-on-dropdownlist-select-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
