`
mywebcode
  • 浏览: 1004573 次
文章分类
社区版块
存档分类
最新评论

ASP.NET中通过文本框的输入实现"拼音码"动态查询的效果

 
阅读更多

HTML核心代码如下:

<asp:TextBox ID="TextBox1" runat="server" Style="position: relative" Width="200px"
AutoPostBack="true" OnTextChanged="TextBox1_Changed"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Style="left: 400px; position: relative; top: 0px"
Text="查询" OnClick="Button1_Click" />
<asp:DropDownList ID="DropDownList1" runat="server" Style="position: relative" Width="200px"
CausesValidation="True" DataTextField="课程名称">
</asp:DropDownList></td>

C#核心代码如下:

protected void TextBox1_Changed(object sender, EventArgs e)
{
SqlDataSource2.SelectCommand = "SELECT 课程名称 FROM course WHERE pinyima LIKE '"+TextBox1.Text+"%'";
DropDownList1.DataSource = SqlDataSource2;
DropDownList1.DataBind();
DropDownList1.Dispose();
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics