在文本框的selectedindex更改上过滤gridview [英] Filter gridview on selectedindex change of textbox
本文介绍了在文本框的selectedindex更改上过滤gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们,请任何人都可以提供帮助,我想在文本框中过滤文本更改中gridview的内容。在页面加载时,gridview已经填充了数据。
谢谢
I guys, Please can anyone help, i want to filter the content of a gridview on text change in a text box. The gridview have already been populated with data when the page loads.
Thanks
推荐答案
hi,
猜你可以在代码隐藏中调用OnTextChanged事件并尝试从那里访问gridview。
代码下面的
可能会有所帮助:
guess u can call OnTextChanged event in the codebehind and try to access the gridview from there.
below code might help:
<asp:textbox id="TextBox1" runat="server" autopostback="true" ontextchanged="text" xmlns:asp="#unknown"></asp:textbox>
数据访问层:
data access layer:
public DataTable populategridview(int id)
{
SqlDataAdapter da = new SqlDataAdapter("select empname from development.dbo.employee where empid='" + id + "'", xconn);
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
Codebehind:
Codebehind:
protected void text(object sender, EventArgs e)
{
DAL obj2 = new DAL();
int id = Convert.ToInt32(TextBox1.Text);
DataTable dtnew = obj2.populategridview(id);
grdview.DataSource = dtnew;
grdview.DataBind();
}
尝试做上面的事情..猜它应该有效..还没试过它...... :)
问候
anurag
try to do somethng like above..guess it should work..havent tested it though...:)
regards
anurag
这篇关于在文本框的selectedindex更改上过滤gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文