简体   繁体   English

从下拉列表中获取文本框中的值

[英]Getting a value in a textbox from a dropdown list

I have a textbox named textbox1 and a dropdownlist. 我有一个名为textbox1的文本框和一个下拉列表。 Dropdownlist contains the list of branches and i want that when i select a branch from dropdown i want to get the respective branch code to be generated in a textbox from the Database or from c# coding. Dropdownlist包含分支列表,我希望当我从下拉列表中选择一个分支时,我想从数据库或c#编码中获取要在文本框中生成的各个分支代码。 How will it be possible ? 怎么可能呢?

我是否想念一些东西,是否只是将事件处理程序放在下拉列表中,以使其在值更改时调用您的方法,该方法可以执行生成文本框字符串所需的任何操作,是否更复杂?

Skipping passed the "database" portion of your question (and assuming your data isn't bound to the DropDownList).. 跳过通过了问题的“数据库”部分(并假设您的数据未绑定到DropDownList)。

One way in ASP.NET, to accomplish this, I believe, is to have your code print DropDownList.SelectedValue's value in the textbox during an event. 我相信,在ASP.NET中实现此目的的一种方法是在事件发生时在文本框中打印代码DropDownList.SelectedValue的值。

Here is a link showing how to bind an event to DropDownList in jQuery 这是显示如何将事件绑定到jQuery中的DropDownList的链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM