Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

searching accessdatasource wildcard for show all

Status
Not open for further replies.

mark222

Programmer
Jul 3, 2007
4
US
I have several fields I am searching an *accessdatasource*

I am using GridView to display the results of the search. I would like the default value to be "all" for any fields the user leaves blank before clicking the search button. In other words if there are 2 fields the user can search by and leaves one blank then I want to disregard the blank field when searching. I think there is a wildcard for this but I can't find it anywhere online. I have tried %, * and others.

Please Help
 
if the field is blank don't search it. Access is already slow enough as it is, you don't want to slow it done more with a predicate [tt]Myfield like '*'[/tt]

Instead use the code behind to append predicates to the datasource.
Code:
protected void MyButton_Click(object sender, EventArgs e){
{
   string text1 = TextBox1.Text;
   string text2 = TextBox2.Text;
   string text3 = TextBox3.Text;
   
   if(!string.IsNullOrEmpty(text1))
   {
       //add predicate to data source for field 1
   }

   if(!string.IsNullOrEmpty(text2))
   {
       //add predicate to data source for field 2
   }

   if(!string.IsNullOrEmpty(text3))
   {
       //add predicate to data source for field 3
   }

   GridView.DataBind();
}

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top