john kanyora

john kanyora

  • NA
  • 242
  • 46.2k

data not loading in gridview

Feb 26 2018 1:26 AM
Hi, i have a code that is using radiobutton to get data from a data table..i want once you click on the radiobutton it display the data on the gridview but it is not doing so..kindly help..below is the code am using.
  1. protected void Radiobuttonlist1_CheckedChange(Object sender, EventArgs e)  
  2. {  
  3. string Value = Radiobuttonlist1.SelectedItem.Value.ToString();  
  4. if (Value == "Patients")  
  5. {  
  6. string connect = TraceBizCommon.Configuration.ConfigSettings.ConnectionString;  
  7. SqlConnection conn = new SqlConnection(connect);  
  8. conn.Open();  
  9. SqlCommand cmd = new SqlCommand("select PatientName,PatientCellPhone from CustomerInformation", conn);  
  10. SqlDataAdapter da = new SqlDataAdapter(cmd);  
  11. DataSet ds = new DataSet();  
  12. da.Fill(ds);  
  13. conn.Close();  
  14. GridView1.DataSource = ds;  
  15. GridView1.DataBind();  
  16. }  
  17. else if(Value== "Suppliers")  
  18. {  
  19. string connect = TraceBizCommon.Configuration.ConfigSettings.ConnectionString;  
  20. SqlConnection conn = new SqlConnection(connect);  
  21. conn.Open();  
  22. SqlCommand cmd = new SqlCommand("select VendorName,VendorPhone from VendorInformation", conn);  
  23. SqlDataAdapter da = new SqlDataAdapter(cmd);  
  24. DataSet ds = new DataSet();  
  25. da.Fill(ds);  
  26. conn.Close();  
  27. GridView1.DataSource = ds;  
  28. GridView1.DataBind();  
  29. }  
  30. else if ( Value== "Employees")  
  31. {  
  32. string connect = TraceBizCommon.Configuration.ConfigSettings.ConnectionString;  
  33. SqlConnection conn = new SqlConnection(connect);  
  34. conn.Open();  
  35. SqlCommand cmd = new SqlCommand("select EmployeeName,EmployeeMobilePhone from PayrollEmployees", conn);  
  36. SqlDataAdapter da = new SqlDataAdapter(cmd);  
  37. DataSet ds = new DataSet();  
  38. da.Fill(ds);  
  39. conn.Close();  
  40. GridView1.DataSource = ds;  
  41. GridView1.DataBind();  
  42. }  
  43. }  

Answers (2)