?
Solved

Dropdownlist - VB2005

Posted on 2006-07-22
1
Medium Priority
?
291 Views
Last Modified: 2008-03-10
How can I do this. When I select an item on Dropdownlist, I want it to display the item on a textbox. Does it has to postback all the time. I'm using Dropdowlist Task and selected Datasource for SQL database.

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click


        Me.TextBox1.Text = Me.DropDownList1.SelectedItem.Text


    End Sub
0
Comment
Question by:VBdotnet2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 9

Accepted Solution

by:
jonorossi earned 500 total points
ID: 17160792
You can use some JavaScript to set the value of the text box with the onchange html select event. Or you could use an AJAX framework like Microsoft Atlas (atlas.asp.net) if you are going to do more than just setting a basic value (eg. getting data from your database).

Here is some javascript that you can use. Take note that ASP.NET changes the names of your controls so you might like to make use of the ClientID property of your controls instead of hardcoding the IDs.

  <script type="text/javascript">
    function setTextBoxValue() {
      var ddl = document.getElementById("ddlTest");
      document.getElementById("txtTest").value = ddl.options[ddl.selectedIndex].value;
    }
  </script>
 
  <select id="ddlTest" onchange="javascript:setTextBoxValue();">
    <option>hey</option>
    <option>bye</option>
  </select>
 
  <input id="txtTest" type="text" />
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

777 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