Subin Thomas

Subin Thomas

  • NA
  • 4.9k
  • 117.6k

cant get record in gridview !!

Feb 25 2019 2:58 AM
i wrote a code where the number is in the db then show the info in gridview when i give valid number it is showing only fields when i give invalid it says no record found in gridview i have used EmptyDataText tag 
 
why is the record not showing 
  1. SqlConnection con = new SqlConnection(pps);  
  2. con.Open();  
  3. SqlCommand cmd = new SqlCommand();  
  4. String sqlquery = "SELECT [ProjectID], [ProjectTitle] FROM [ProjectDetails] where [UserID] like '%'+@userid+'%'";  
  5. cmd.CommandText = sqlquery;  
  6. cmd.Connection = con;  
  7. cmd.Parameters.AddWithValue("userid", txtempsearch.Text);  
  8. DataTable dt = new DataTable();  
  9. SqlDataAdapter sda = new SqlDataAdapter(cmd);  
  10. sda.Fill(dt);  
  11. GridVSearch.DataSource = dt;  
  12. GridVSearch.DataBind(); 
 

Answers (3)