3
Answers

cant get record in gridview !!

Subin Thomas

Subin Thomas

6y
1.1k
1
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)