protected void Page_Load(object sender, EventArgs e) { string cs = ConfigurationManager.ConnectionStrings["LibraryDatabase"].ToString(); using (SqlConnection con = new SqlConnection(cs)) { SqlCommand cmd = new SqlCommand("select * from tblBooks where Title=@TITLE", con); cmd.Parameters.AddWithValue("@TITLE", DropDownList1.SelectedValue); SqlCommand cmd1 = new SqlCommand("select Title from tblBooks",con); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); GridView1.DataSource = rdr; GridView1.DataBind(); rdr.Close(); SqlDataReader rdr1 = cmd1.ExecuteReader(); while (rdr1.Read() == true) { DropDownList1.Items.Add(new ListItem( rdr1["Title"].ToString())); } rdr1.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if(!ispostback) { //put your code here } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)