Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1033475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:14:17+00:00 2026-05-16T14:14:17+00:00

I have a drop-down list which gathers data from the database and a textbox

  • 0

I have a drop-down list which gathers data from the database and a textbox which contains the text from the drop-down list when I select a value from the drop-down list. I tried to make this work, but no data appears in the textbox when I select a value from the drop-down list and no errors appear either. Can anyone help me?

aspx Code:

<table id="Tbl" runat="server" width="70%" border="1" cellspacing="1" cellpadding="1">
        <tr>
            <td>
                Select
            </td>
            <td>
                <asp:SqlDataSource ID="SDSOption" runat="server" ConnectionString="Data Source=ELARABY-1EACFA3\SQLEXPRESS;Initial Catalog=ElarabyGroup;Integrated Security=True"
                    ProviderName="System.Data.SqlClient" SelectCommand="SELECT [Id], [option] FROM [Option]">
                </asp:SqlDataSource>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SDSOption" DataTextField="option"
                            DataValueField="Id" ondatabound="DropDownList1_DataBound" 
                            onselectedindexchanged="DropDownList1_SelectedIndexChanged">
                        </asp:DropDownList>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" />
                    </Triggers>
                </asp:UpdatePanel>
            </td>
            <td>
                <b style="font-style: italic">Select Option</b> <b style="font-style: italic">
                    <br />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TxtOption"
                        Display="Dynamic" ErrorMessage="*" SetFocusOnError="True"><b style="font-style: italic">*</b></asp:RequiredFieldValidator>
                </b>
            </td>
        </tr>
        <tr>
            <td class="style2">
                <asp:Label ID="LblOption" runat="server" Text="Option"></asp:Label>
            </td>
            <td class="style1">
                <asp:TextBox ID="TxtOption" runat="server"></asp:TextBox>
            </td>
            <td>
                <b style="font-style: italic">Note:Add Here Product Option</b> <b style="font-style: italic">
                    <br />
                    <asp:RequiredFieldValidator ID="RVOption" runat="server" ControlToValidate="TxtOption"
                        Display="Dynamic" ErrorMessage="*" SetFocusOnError="True"><b style="font-style: italic">*</b></asp:RequiredFieldValidator>
                </b>
            </td>
        </tr>
        <tr style="font-style: italic">
            <td class="style2">
                &nbsp;
            </td>
            <td>
                <asp:Button ID="BtnSubmit" runat="server" Height="20px" Text="Submit" Width="50px"
                    OnClick="BtnSubmit_Click" />
                &nbsp;
            </td>
            <td align="left">
                &nbsp; <b><i><span><a href="EditOption.aspx">
                    <asp:Image ID="Image1" runat="server" ImageUrl="~/Backend/Image/www_4photos_net_1137678404.jpg"
                        Width="60px" /></a> Display Other </span></i></b>
            </td>
        </tr>
    </table>

CS Code:

 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        TxtOption.Text += DropDownList1.SelectedItem.Value;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:14:17+00:00Added an answer on May 16, 2026 at 2:14 pm

    The DropDownList is wrapped in an UpdatePanel, but the TextBox is not.

    What this means is during the asychronous postback (triggered on the SelectedIndexChanged event), the postback only has visiblity of the controls inside the UpdatePanel (as this is all that gets submitted to the server).

    Because the TextBox is outside the UpdatePanel, it does not have visibility of it during the async postback.

    The easiest solution would be to put the Textbox inside the UpdatePanel.

    Another solution would be to use ScriptManager.RegisterStartupScript to set the value of the control from the SelectedIndexChanged event using basic JavaScript (which has access to the entire DOM, unlike the asynchronous postback).

    E.g

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(UpdatePanel1, 
        this.GetType(), 
        "NameOfScript", 
        string.Format("document.getElementById('{0}').value = '{1}';",
        txtOption.ClientId,
        DropDownList1.SelectedValue));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a drop down list which is populated dynamically from database table i.e
I have one drop down list in my page, which contains two options. What
I have a drop-down list which causes a text-area to populate with different text
Basically I have a drop down list which is populated with text and values
I have a drop down list (ddlAccount) which i can choose an item from
I have a drop down list <select onchange=alert(this.value);> <option selected=selected value=cat>cat</option> <option value=dog>dog</option> </select>
I have a page, it has a drop down list, which contains the names
I want to fetch a selected value from a drop down 'select' list of
I have a drop down list (ddlFilterBuildings) which contains a list of buildings to
I have a drop-down list as, <select id='idleReason' onChange=loadXMLDoc(this.value) size=1> <option value=nothing selected=selected>Select a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.