Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. protected void Button1_Click(object sender, EventArgs e)
  2. {
  3. if (DropDownList1.SelectedItem.ToString() =="ER00 - File Header")
  4. {
  5. using (SqlConnection con =
  6. new SqlConnection(ConfigurationSettings.AppSettings["DBcon"]))
  7. {
  8. if (String.IsNullOrEmpty(TextBox_ID.Text.ToString()))
  9. {
  10. lbl_NoBatchID.Text = "Please enter BatchID!";
  11. }
  12. else
  13. {
  14. try
  15. {
  16. SqlCommand sqlCommand = new SqlCommand(
  17. "Select * from tbl_WinApps_FileHeader Where BatchID =" +
  18. TextBox_ID.Text.ToString());
  19.  
  20. sqlCommand.Connection = con;
  21. con.Open();
  22. SqlDataReader read = sqlCommand.ExecuteReader();
  23.  
  24. GridView1.DataSource = read;
  25. GridView1.DataBind();
  26. }
  27. catch (Exception)
  28. {
  29. }
  30. }
  31. }
  32. }
  33. }
  34.  
  35. if (String.IsNullOrEmpty(TextBox_ID.Text.ToString()))
  36. {
  37. lbl_NoBatchID.Text = "Please enter BatchID!";
  38. GridView1.DataSource=null;
  39. GridView1.DataBind();
  40. }
  41. else
  42. {
  43.  
  44. catch(Exception e){
  45. }
  46. lbl_NoBatchID.Text = "";
  47.  
  48. protected void Button1_Click(object sender, EventArgs e)
  49. {
  50. if (DropDownList1.SelectedItem.ToString() =="ER00 - File Header")
  51. {
  52.  
  53. using (SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["DBcon"]))
  54. {
  55. if (String.IsNullOrEmpty(TextBox_ID.Text.ToString()))
  56. {
  57. lbl_NoBatchID.Text = "Please enter BatchID!";
  58.  
  59. }
  60. else
  61. {
  62. try
  63. {
  64.  
  65. SqlCommand sqlCommand = new SqlCommand("Select * from tbl_WinApps_FileHeader Where BatchID =" + TextBox_ID.Text.ToString());
  66. sqlCommand.Connection = con;
  67. con.Open();
  68. SqlDataReader read = sqlCommand.ExecuteReader();
  69.  
  70. GridView1.DataSource = read;
  71. GridView1.DataBind();
  72. lbl_NoBatchID.Text = "";
  73. }
  74. catch (Exception)
  75. {
  76.  
  77. }
  78.  
  79. }
  80. }
  81.  
  82. }
  83.  
  84. lbl_NoBatchID.Text = "";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement