在网上看到Web combox 之前
想实现可编辑下拉菜单
只能根据 textbox span dropdownlist 模拟
前台代码:
<body>
<form id="Form1" method="post" runat="server">
<br />
<asp:DropDownList ID="DropDownList1" runat="server" CssClass="ip" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged1" Width="196px" />
<asp:Button ID="Button1" runat="server" CssClass="btn1" OnClick="Button1_Click1"
Text="Button" />
<asp:TextBox ID="TextBox2" runat="server" CssClass="ip"></asp:TextBox><br /><br />
<span style="border-top: #ffffff 1pt solid; left: 6px; border-left: #ffffff 1pt solid;
width: 199px; border-bottom: #ffffff 1pt solid; position: absolute; top: 14px;
height: 11px; border-right: #ffffff 1pt solid;" id="SPAN1">
<asp:TextBox ID="TextBox1" runat="server" CssClass="ip" BorderStyle="Groove" Width="179px" /></span>
</form>
</body>
后台代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
PublicVar.sqlstr = "select id,name from users";
PublicFunction.DropDownList_SHATDB(DropDownList1, PublicVar.sqlstr, 1);//邦定数据库
}
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
TextBox1.Text = DropDownList1.SelectedItem.Text.Trim().ToString();
}
protected void Button1_Click1(object sender, EventArgs e)
{
TextBox2.Text = TextBox1.Text;
}
}