Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
private void SearchData()
  {
    try
    {
      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ToString());
      con.Open();
      SqlDataAdapter ad = new SqlDataAdapter("Select SrNo,Name,Convert(varchar,Birth,103)as Birth ,Age from Rnd",
                          con);
      DataSet ds = new DataSet();
      ad.Fill(ds, "Rnd");
      con.Close();
      GridView1.DataSource = ds.Tables["Rnd"];
      GridView1.DataBind();
    }
    catch (Exception exec)
    {
      ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Message", "alert('" + exec.ToString() + "')", true);
    }

}
Posted
Updated 14-Jan-11 23:52pm
v3
Comments
Estys 15-Jan-11 3:59am    
Stop it! Ask a question.
OriginalGriff 15-Jan-11 4:13am    
Reason for my vote of 1: Please stop asking meaningless questions: "Is it right?" is not a lot of use when we do not know what you are trying to do.
#realJSOP 15-Jan-11 5:52am    
Not a question (removed "(Is it right)" from title

No, the above code does not do any 'search' in gridview.

It does not search anything specific and return nor any filter code present.

Did you try anything?
 
Share this answer
 
Not a question, and removed "(Is it right)" from title. We can't tell you if your code is "right", because we don't have (nor do we want) all of your code. If it compiles, run it under the debugger. If it's not right, you'll know in short order.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900