Solved

Dropdownlist - VB2005

Posted on 2006-07-22
1
287 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 125 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Form Data Disappears Using Back Button 4 21
asp Google Map 2 64
Why use this lambda? 12 65
asp.net get gridview datakey from row command 2 16
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…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

733 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