Gridview和Textbox通过使用where条件 [英] Gridview and Textbox by using where condition

查看:72
本文介绍了Gridview和Textbox通过使用where条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,先生,

我是Rakesh P.

我有一个关于Gridview和Textbox的简单问题.

我在数据库中有表"EMP".现在我有文本框和按钮,并且Gridview在页面上

当我在文本框中输入empid时,我想在gridview中显示特定empid的结果.我试图通过使用where子句来实现它,但是它显示了文本框无法与gv绑定的错误


请帮我...


-Rakesh

Hi Sir,

I am Rakesh P.

I have a simple issue about Gridview and Textbox .

I have table "EMP" in database. now I have textbox and button & Gridview ON PAGE

I want to display result for particular empid in gridview when i enter empid in text box . I tried to implement it by using where clause but it shows error that textbox can''t bound with gv


Please help me ...


-Rakesh

推荐答案

请参考以下线程:

该线程将向您展示如何搜索ASP.NET GridView数据的所有列,并仅显示满足搜索文本的那些数据:带有DropDownList的GridView筛选器表达式ASP.NET [^ ]

ASP.NET GridView过滤 [ ^ ]

还可以查看此CP文章,这将为您提供一个从GridView派生的自定义控件,实现过滤,自定义首页传呼机和自定义底部传呼机.
具有分页和过滤功能的自定义GridView [ ASP.NET的可过滤网格 [带有搜索选项(SearchableGridView)的ASP.NET GridView [在具有搜索功能的GridView中显示大量数据 [带有搜索选项(SearchableGridView)的ASP.NET GridView [ GridView多个过滤器AJAX控件 [
Please refer following threads:

This thread will show you how to search through all columns of ASP.NET GridView Data and show only those data which satisfies the search text: How to search through GridView records[^]

This example describes how to use GridView Filtering or Filter Gridview with DropDownList: GridView Filter Expression with DropDownList ASP.NET[^]

ASP.NET GridView Filtering[^]

Also have a look on this CP Article, this will give you a Custom control derived from GridView, implements filtering, custom Top pager, and custom Bottom pager.
Custom GridView with Paging and Filtering[^]

..and some more:
Filterable Grid for ASP.NET[^]
ASP.NET GridView with search option (SearchableGridView)[^]

Display Large Amount of Data in GridView with Search Functionality[^]
ASP.NET GridView with search option (SearchableGridView)[^]
GridView Multiple Filter AJAX Control[^]



检查此
如何使用文本框搜索记录 [ ^ ]
最好的问候
M.Mitwalli
Hi ,
Check this
how to search the records using textbox[^]
Best Regards
M.Mitwalli


直肌,

请尝试这样

Hi Rectus,

Please try like this

protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection Cn = new SqlConnection("server=OM-PC;database=master;uid=SA;pwd=123");
        
        string query="SELECT * FROM DEPT WHERE DNO="+ Convert.ToInt32(TextBox1.Text);

        //if your department number contains any character 
        string query="SELECT * FROM DEPT WHERE DNO=''"+ Convert.ToInt32(TextBox1.Text)+"''";

        SqlCommand Cmd = new SqlCommand(query, Cn);
        Cn.Open();
        SqlDataReader Dr = Cmd.ExecuteReader();
        GridView1.DataSource = Dr;
        GridView1.DataBind();
        Dr.Close();
        Cn.Close();

    }
}



希望这对您的问题有所帮助.如果有帮助,请解决.

谢谢与问候
苏曼·扎洛迪亚(Suman Zalodiya)



I hope this will help you in your problem. Please make it resolved if it helps you.

Thanks and Regards
Suman Zalodiya


这篇关于Gridview和Textbox通过使用where条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆