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();

        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;

        if (objDs.Tables.Count == 0)
            lblNoRecords.Visible = true;
            GridView1.DataSource = objDs;

    public void ItemDataBoundEventHandler1(object sender, GridViewRowEventArgs e)
        if (e.Row.RowType == DataControlRowType.DataRow)
            e.Row.Attributes.Add("onmouseover", "'Silver'");
            e.Row.Attributes.Add("onmouseout", "'#FFFBD6'");
    protected void btnSearch_Click(object sender, EventArgs e)
Who is Participating?
sasapopovicConnect With a Mentor Commented:
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.
All Courses

From novice to tech pro — start learning today.