Subin Thomas

Subin Thomas

  • NA
  • 4.9k
  • 117.3k

im getting an error when fetching data into gridview

Apr 30 2019 5:55 AM
i have a gridview with project names with autogenerated select button when select button is selected bellow code is executed
  1. protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)  
  2.        {  
  3.   
  4.            lblProjectno.Text = GridView1.SelectedRow.Cells[1].Text;  
  5.      
  6.            String s1 = lblProjectno.Text;  
  7.   
  8.   
  9.            SqlConnection con = new SqlConnection(ppd_Vas);  
  10.            con.Open();  
  11.            SqlCommand cmd = new SqlCommand("query'", con);  
  12.   
  13.            cmd.Parameters.AddWithValue("@ProjectNo", s1);  
  14.            SqlDataAdapter da = new SqlDataAdapter(cmd);  
  15.   
  16.      
  17.            DataSet ds = new DataSet();  
  18.   
  19.            da.Fill(ds);  
  20.   
  21.            GridView2.DataSource = ds;  
  22.            GridView2.DataBind();  
  23.   
  24.            con.Close();  
  25.   
  26.            GridView5_Show();  
  27.            DisplayProject();  
  28.            Panelprojectdashboard1.Visible = true;  
  29.            Bindchart1();  
  30.            BindChart2();  
  31.   
  32.   
  33.   
  34.        } 
 above code generates a gridview after selecting the select button
in above code i have mentioned a function call Gridview5_show()
 
 
code of  Gridview5_show() is bellow
  1. protected void GridView5_Show()  
  2.         {  
  3.             string s1 = GridView1.SelectedRow.Cells[1].Text;  
  4.   
  5.   
  6.   
  7.   
  8.             SqlConnection con = new SqlConnection(ppd_Vas);  
  9.             con.Open();  
  10.   
  11.             SqlCommand cmd = new SqlCommand("query ", con);  
  12.   
  13.             cmd.Parameters.AddWithValue("@ProjectNo", s1);  
  14.             SqlDataAdapter da = new SqlDataAdapter(cmd);  
  15.   
  16.             DataSet ds = new DataSet();  
  17.             da.Fill(ds);  
  18.             GridView5.DataSource = ds;  
  19.             GridView5.DataBind();  
  20.             con.Close();  
  21.   
  22.   
  23.         } 
  but when im selecting the select button it is showing error at  line 17 da.Fill(ds);
 
error is : Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
 

Answers (9)