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

  • SEARCH
  • Home
  • 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 3390928
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:44:51+00:00 2026-05-18T03:44:51+00:00

i want to filter the gridview on textchange in search textbox…. if i press

  • 0

i want to filter the gridview on textchange in search textbox….
if i press some character like “S” the gridview should filled up with record starting with “S”.

Public class DALDepartment
{
public Dataset DepartmentSearch(string Connectionstring, string conditon)
{
 SqlConnection connection = new SqlConnection(connectionstring);
            SqlCommand command = new SqlCommand("select departmentname,departmentcode from Department" + condition, connection);                  
            SqlDataAdapter adapter = new SqlDataAdapter(command);
            DataSet ds = new DataSet();
            try
            {
                connection.Open();            //Opening Connection                
                adapter.Fill(ds, "Department");      //Filling values to Dataset from Adapter
                connection.Close();          //closing connection
            }
            catch (Exception e)
            {
                ErrorCollection.AddErrors("XMS0000", e.Data + e.Message);
                return null;
            }
            return ds;
          }   
       }

//Dep.Aspx.cs in the asp page
DataSet ds = new DataSet();
        string condition = "where departmentname LIKE '%" + Textbox1.Text + "%'" ;
        ds=DepartmentSearch(Connectionstring,condition);
        GridView1.DataSource = ds.Tables["Department"];
        GridView1.DataBind();

Thw above code works fine. now i need to sort this in the dataset. which i got stored inside the dataset, when the pageload.
For Exampe:

 //The Data's are found and loaded in a dataset

 SqlCommand command = new SqlCommand("select departmentname,departmentcode from
 Department" , connection);
            SqlDataAdapter adapter = new SqlDataAdapter(command);
            DataSet ds = new DataSet();
                connection.Open();         
                adapter.Fill(ds, "Department");
                connection.Close();          


//In dataset

 DataSet ds = new DataSet();
 ds = DepartmentSearch(Connectionstring);

Now i don’t know how to Filter the values inside the dataset.

I want to thank you friends in advance for your answers and suggestion.

  • 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-05-18T03:44:51+00:00Added an answer on May 18, 2026 at 3:44 am

    You can use Select function in the case of DataTable
    ie

    dtNames.Select(“name like ‘a%'”);

    So you will be sorts the name .Remember that name must be a column of your datatable.So for next time you can search only by changing the alphabet no need for executing the query.But this method will retrieve only data which is available only when the first query executes.If any changes were occurred to database then it will reflect only after executing the query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to filter some reserved word on my title form. $adtitle = sanitize($_POST['title']);
I am trying to filter a gridview with a filter expression like this SurName
I have a Gridview that I want to filter. My gridview is in an
I have a GridView with an EntityDataSource. I want to filter the rows at
I have an string like this:- $sa_position = state/Gold,International/Participant,School/Participant,School/Bronze,national/Bronze,School/Gold; And I want filter this
I want to filter records on 'Email' my query is like this. SELECT *
I want to filter my model object using two filters. So, it can be
I want to filter a java.util.Collection based on a predicate.
I want to filter repeated elements in my list for instance foo = ['a','b','c','a','b','d','a','d']
I want to filter e-mail headers received on my Postfix mail receiving server. I

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.