Skip to content

Search from gridview in C#

shibasankar behera

Asked Sep 4, 2013, 10:16 PM EDT1 answer
Share
LinkedInX
when I am searching  for some records in gridview, the error message is showing like
"Specified argument was out of the range of valid values"

the code is:

Java
con.Open();
string query = "select Name from View where ID like'" + txtID.Text +"%'";
            SqlDataAdapter da = new SqlDataAdapter(query, con);
            DataSet ds = new DataSet();
            da.Fill(ds);
            if (ds.Tables[0].Rows.Count > 0)
            {
                GridViewItm.DataSource = ds;
                GridViewItm.DataBind();
                GridViewItm.Show();
            }
            else
            {
                Response.Write(@"<script language='javascript'>alert('Requested Records Not Found')</script>");
            }

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    hi,

     put a breakpoint at line-> string query,
    run the visual studio, and when this line comes you select the query and copy it, and paste it in sql, execute it..
    and check error is coming or not, nd see where u did wrong in query, and change the query
    0