Advertisement
Guest User

Untitled

a guest
Feb 1st, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data;
  8. using System.Configuration;
  9. using System.Data.SqlClient;
  10.  
  11.  
  12. public partial class distt : System.Web.UI.Page
  13. {
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16. /* SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ConnectionString);
  17. if (con.State == ConnectionState.Closed)
  18. {
  19. con.Open();
  20. }*/
  21. if (!IsPostBack)
  22. {
  23. Bind();
  24.  
  25. }
  26. }
  27. protected void DisttList_SelectedIndexChanged(object sender, EventArgs e)
  28. {
  29.  
  30. }
  31. protected void BlockList_SelectedIndexChanged(object sender, EventArgs e)
  32. {
  33. }
  34. protected void Bind()
  35. {
  36. SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ConnectionString);
  37. if (con.State == ConnectionState.Closed)
  38. {
  39. con.Open();
  40. }
  41. SqlCommand cmd = new SqlCommand("Select Distt_ID,Distt_Name FROM Distt_tb" +
  42. "INNER JOIN Block_tb ON Distt_tb.Distt_ID = Block_tb.Distt_ID ", con);
  43. SqlDataAdapter da = new SqlDataAdapter(cmd);
  44. DataSet ds = new DataSet();
  45. da.Fill(ds);
  46. DisttList.DataSource = ds;
  47. DisttList.DataTextField = "Distt_Name";
  48. DisttList.DataValueField = "Distt_Id";
  49. DisttList.DataBind();
  50. DisttList.Items.Insert(0, new ListItem("--Select--", "0"));
  51. blockbind();
  52. // panchbind();
  53.  
  54. }
  55. protected void blockbind()
  56. {
  57. SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ConnectionString);
  58. if (con.State == ConnectionState.Closed)
  59. {
  60. con.Open();
  61. }
  62. SqlCommand cmd = new SqlCommand("Select Block_ID,Block_Name FROM Block_tb", con);
  63. SqlDataAdapter da = new SqlDataAdapter(cmd);
  64. DataSet ds = new DataSet();
  65. da.Fill(ds);
  66. BlockList.DataSource = ds;
  67. BlockList.DataTextField = "Block_Name";
  68. BlockList.DataValueField = "Block_ID";
  69. BlockList.DataBind();
  70. BlockList.Items.Insert(0, new ListItem("--Select--", "0"));
  71. con.Close();
  72. panchbind();
  73. }
  74. protected void panchbind()
  75. {
  76.  
  77. SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ConnectionString);
  78. if (con.State == ConnectionState.Closed)
  79. {
  80. con.Open();
  81. }
  82.  
  83. SqlCommand cmd = new SqlCommand("Select Panch_ID,Panch_Name FROM Panch_tb", con);
  84. SqlDataAdapter da = new SqlDataAdapter(cmd);
  85. DataSet ds = new DataSet();
  86. da.Fill(ds);
  87. PanchList.DataSource = ds;
  88. PanchList.DataTextField = "Panch_Name";
  89. PanchList.DataValueField = "Panch_Id";
  90. PanchList.DataBind();
  91. PanchList.Items.Insert(0, new ListItem("--Select--", "0"));
  92. con.Close();
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement