日期:2014-05-16 浏览次数:20386 次
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
string id = TextBox1.Text;
SqlParameter[] val = new SqlParameter[] {
new SqlParameter("@id",id)
};
string sql = "select color from ruku where id=@id";
DataTable dt = DAL.DBHelper.GetDataSet(sql,val);
//DataTable dt1 = new DataTable();
//dt1.Columns.Add("col", typeof(System.String));
List<string> list = new List<string>();
foreach (DataRow r in dt.Rows)
{
string vale = r["color"].ToString();
if (!list.Contains(vale))
{
list.Add(vale);
}
}
DropDownList1.DataSource = list;
DropDownList1.DataBind();
}
<div>
编号:<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
颜色:<asp:DropDownList ID="DropDownList1" Width="100px" runat="server">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="查 询" Width="94px" OnClientClick="return fun()"
OnClick="Button1_Click" />
</div>