Solved

Text Box Needs to Display the Selection from the Dropdown Box

Posted on 2014-01-29
1
430 Views
Last Modified: 2014-01-29
need my text box or some text somewhere on my form to display the value selected from my dropdown box.

Example - if an Author's genre of Fiction is selected, the textbox should display Fiction. How do I do this?

I can not use the PageLoad event because that event hides some other fields on the page. I think I need to include something in the selectedindexchange event.

Here is my code:

protected void AuthorsList_SelectedIndexChanged(object sender, EventArgs e) 
    { 
  
  
  
    } 

Open in new window

asp:DropDownList runat="server" ID="lbAuthorsList"  
       style="float:left;" DataSourceID="odsAuthorsList"  
       DataTextField="DisplayName" DataValueField="AuthorName"  
       onselectedindexchanged="AuthorsList_SelectedIndexChanged"  
       AutoPostBack="true" AppendDataBoundItems="true" > 
</asp:DropDownList>    
  <asp:TextBox id="tb4" Text="Hello World!" runat="server"  
        ondatabinding="AuthorList_SelectedIndexChanged" /> 
  
 <asp:ObjectDataSource ID="odsAuthors" runat="server"  
            SelectMethod="GetAuthorsGenresList" TypeName="GenreSelection"> 
        </asp:ObjectDataSource> 
  
  

Open in new window

0
Comment
Question by:programmher
1 Comment
 
LVL 9

Accepted Solution

by:
dustock earned 250 total points
ID: 39818500
The selected Index changed event will allow you to do what your asking and I see AutoPostBack is already set to true.  If you are selecting Fiction from the drop down the code should be something like

tb4.Text = AuthorsList.Text;

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now