单个按钮上的多个列中的多个TextBox搜索记录单击 [英] Search Record with Multiple TextBox in Multiple Columns On Single Button Click

查看:68
本文介绍了单个按钮上的多个列中的多个TextBox搜索记录单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在多个列中使用多个文本框搜索记录在单个按钮上单击此按钮 -



http://s9.postimg.org/mm65gbxxr/Design_Search_Application_like_this_and_clear_co.png [ ^ ]



检查Null值是否为



  if (TextBox2.Text ==  
{

然后通过列搜索 名称
}
else if (TextBox3.Text ==
{

通过RollNumber搜索

}





只是想知道一个更好的想法来执行搜索任何人都可以建议我提前感谢:)

解决方案

我通常会有一个SP进行搜索。

对于未指定的搜索条件,SP的参数将为null。



SQL的位置如下所示:



  WHERE  

table .Name =(IsNull( @ Name table .Name))
< span class =code-keyword> AND
table .RollNumber =(IsNull( @ RollNumber .RollNumber))


您可以构建动态查询,



在执行i之前t。



  string  qry =  从表格中选择详细信息; 

if (txtbox1.text ==
qry + = rollno = + txtbox2 。文本;
if (textbox2.text ==
qry + = name = + txtbox1.text;


I want to search Record using Multiple Textboxes in Multiple Columns On single Button click like this-

http://s9.postimg.org/mm65gbxxr/Design_Search_Application_like_this_and_clear_co.png[^]

Would it be Good To check for Null Values to search result like

 if (TextBox2.Text == "")
       {

Then Search Via Column "Name"
}
else if(TextBox3.Text == "")
{

Search Via RollNumber

}



Just Want to know a Better idea to perform search can anybody suggest me thanks in advance :)

解决方案

I''d normally have an SP doing the search.
The parameters for the SP would be null for the search criteria not specified.

The WHERE of the SQL woulld read something like

WHERE

table.Name = (IsNull(@Name, table.Name))
AND
table.RollNumber = (IsNull(@RollNumber, table.RollNumber))


You can build the query dynamic instead ,

before executing it.

string qry="select details from table where";

if(txtbox1.text=="")
qry+="rollno ="+txtbox2.text;
if(textbox2.text=="")
qry+="name="+txtbox1.text;


这篇关于单个按钮上的多个列中的多个TextBox搜索记录单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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