Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9179577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:49:56+00:00 2026-06-17T17:49:56+00:00

I want to search rows in my DataTable . I’ve tried this: protected void

  • 0

I want to search rows in my DataTable.

I’ve tried this:

 protected void imggastsuche_Click(object sender, EventArgs e) 
        {
            string searchstring = txtgastsuche.Text;

            DataTable tb = DataBaseManager.GetDataTable(mysqlconnectionstring);

            DataRow[] foundRows = tb.Select("FIRSTNAME,LASTNAME,NAME,COMPANY,TIMEFROM,TIMETO,CREATOR Like '%" + searchstring + "%'");

            tb = foundRows.CopyToDataTable();

            this.ListView.DataSource = tb;
            this.ListView.DataBind();

        }

But I have an error in my string.

What can I do if I want to search these columns?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:49:57+00:00Added an answer on June 17, 2026 at 5:49 pm

    You get the error because the parameter to Select is the filterExpression and you have passed all columns. Understand the filterExpression as a WHERE clause in sql. You want all columns but you want to filter by just one. You get all columns anyway since they are all part of the DataTable/DataView so you don’t need to list them explicitely.

    You could either use the DataTable.Select, DatView.RowFilter methods or LINQ-to-DataSet:

    LINQ-To-DataSet (which i prefer):

    var filtered = tb.AsEnumerable()
        .Where(r => r.Field<String>("CREATOR").Contains(searchstring));
    

    ADO.NET(DataTable.Select):

    DataRow[] filteredRows = tb.Select("CREATOR LIKE '%" + searchstring + "%'");
    

    ADO.NET(DataView.RowFilter):

     tb.DefaultView.RowFilter = "CREATOR LIKE '%" + searchstring + "%'";
    

    If you want to search for this string in any column instead:

    DataRow[] filteredRows = tb.Select("FIRSTNAME LIKE '%" + searchstring + "%' OR LASTNAME LIKE '%" + searchstring + "%' OR NAME LIKE '%" + searchstring + "%' OR COMPANY LIKE '%" + searchstring + "%' OR CREATOR LIKE '%" + searchstring + "%'");
    

    The same with Linq:

    var filtered = tb.AsEnumerable()
        .Where(r => r.Field<String>("FIRSTNAME").Contains(searchstring)
               ||   r.Field<String>("LASTNAME").Contains(searchstring))
               ||   r.Field<String>("NAME").Contains(searchstring)
               ||   r.Field<String>("COMPANY").Contains(searchstring)
               ||   r.Field<String>("CREATOR").Contains(searchstring));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to search two item (name=string and location=json). this search is (one input
I want to search for a string in DataTable if it starts with null
I want to search no of rows containing ' aphostrophe string in a particular
I've got this Excel Workbook which I want to search for a specific string
I want to search in a database table for the number of rows of
Windows command line, I want to search a file for all rows starting with:
I use a DataTable with Information about Users and I want search a user
Q: How can i make mysql query search in multiple rows What i want
I want search those rows that do not contain rajasthan in the state field
I want to search relevant Row in List views rows which type in edittext

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.