public void area() { if (ddlplace.SelectedItem.Value == "yes") { if (con.State == ConnectionState.Closed) { con.Close(); } SqlCommand cmd = new SqlCommand("select delivery_charges,tax,shipping from delivery ", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); ddlplace.DataSource = ds; ddlplace.DataTextField = "area"; ddlplace.DataValueField = "area"; ddlplace.DataBind(); con.Close(); }
if (con.State == ConnectionState.Closed) { con.Open(); }
{ if (!IsPostBack) { // Declare objects // Read the connection string from Web.config string connectionString = ConfigurationManager.ConnectionStrings[ ""].ConnectionString; // Initialize connection conn = new SqlConnection(connectionString); SqlCommand = new SqlCommand( "select delivery_charges,tax,shipping from delivery", conn); try { // Open the connection conn.Open(); // Execute the command reader = SqlCommand.ExecuteReader(); // Populate the list of area ddlplace.DataSource = reader; ddlplace.DataValueField = "area"; ddlplace.DataTextField = "area"; ddlplace.DataBind(); // Close the reader reader.Close(); } finally { // Close the connection conn.Close(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)