gridview search functionality

Hi experts,

I have a grid view control with should be populated with what is searched for in this site. somehow can't write the search code

need assistance!!


 public void PopulateGrid()
    {
        DataSet objDs = new DataSet();

        System.Data.SqlClient.SqlConnection
        myConnection = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["X10REPDConnectionString"].ConnectionString);
        System.Data.SqlClient.SqlDataAdapter  myCommand;
        myCommand = new System.Data.SqlClient.SqlDataAdapter("MP_CheckStaffExists", myConnection);
        myCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
        myConnection.Open();
        myCommand.Fill(objDs);

        if (objDs.Tables.Count == 0)
            lblNoRecords.Visible = true;
        else
        {
            GridView1.DataSource = objDs;
            GridView1.DataBind();
        }
    }

    public void ItemDataBoundEventHandler1(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='Silver'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFBD6'");
        }
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
       
       
    }
}
SirReadAlotAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sasapopovicCommented:
Hi SirReadAlot,

You should:
 - call your PopulateGrid() method from btnSearch_Click
 - modify PopulateGrid() method to accept a few parameters; those parameters would be values from text boxes where users will type-in their search criteria
 - add input parameters (search criteria) to your stored procedure (MP_CheckStaffExists)
 - add input parameters of stored procedure to myCommand  object.

Hope this will help.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.