如何使用文本框插入下拉列表 [英] How to insert the dropdown list with textbox
本文介绍了如何使用文本框插入下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想显示部门值,我只使用一个下拉列表。请给我任何帮助。
Hi,
I want to display the Department values, I'm using only one dropdownlist.Please any one help to me.
<asp:DropDownList ID="dropdown1" runat="server" AutoPostBack="true">
<asp:ListItem Text="CSC" Value="CSC"></asp:ListItem>
<asp:ListItem Text="ECE" Value="ECE"></asp:ListItem>
<asp:ListItem Text="EEE" Value="EEE"></asp:ListItem>
<asp:ListItem Text="MECH" Value="MECH"></asp:ListItem>
<asp:ListItem Text="Other" Value="Other"></asp:ListItem>
</asp:DropDownList>
<td>
<asp:TextBox ID="txtDept" runat="server"></asp:TextBox>
</td>
谢谢,
Thanks,
推荐答案
Your solution is very simple given below if it is not your solution then ask again
In ASPX
<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeBehind="Default.aspx.vb" Inherits="WebApplication4VB._Default" %>
<asp:content id="HeaderContent" runat="server" contentplaceholderid="HeadContent" xmlns:asp="#unknown">
</asp:content>
<asp:content id="BodyContent" runat="server" contentplaceholderid="MainContent" xmlns:asp="#unknown">
<asp:dropdownlist id="dropdown1" runat="server" autopostback="true" onselectedindexchanged="dropdown1_SelectedIndexChanged">
<asp:listitem text="CSC" value="CSC"></asp:listitem>
<asp:listitem text="ECE" value="ECE"></asp:listitem>
<asp:listitem text="EEE" value="EEE"></asp:listitem>
<asp:listitem text="MECH" value="MECH"></asp:listitem>
<asp:listitem text="Other" value="Other"></asp:listitem>
</asp:dropdownlist>
Name of the Department: <asp:textbox id="txtDept" runat="server"></asp:textbox>
</asp:content>
In Code behind .vb
Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub dropdown1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dropdown1.SelectedIndexChanged
txtDept.Text = dropdown1.SelectedValue.ToString()
End Sub
End Class
这篇关于如何使用文本框插入下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文