I want to search rows in my DataTable
.
I\'ve tried this:
protected void imggastsuche_Click(object sender, EventArgs e)
{
you could build the query you are going to use in the select.
if(TextBoxCusName.Text != "")
{
query = "CustomerName LIKE '%" + TextBoxCusName.Text.Trim()+"%' AND ";
}
if(TextBoxCusContact.Text != "")
{
query = query + "CustomerNo LIKE '%" + TextBoxCusContact.Text.Trim() + "%' AND ";
}
if(TextBoxVehicleNo.Text != "")
{
query = query + "VehicleNo LIKE '%" + TextBoxVehicleNo.Text.Trim()+"%'";
}
if(query.EndsWith("AND "))
{
query = query.Remove(query.Length - 4);
}
DataRow[] result = dataCustomerAndVehicle.Select(query);
this equivalent to
select * from dataCustomerAndVehicle where CustomerName LIKE '%...%' AND ...