none
Populate combobox

    Question

  • i have 2 combo, cboCountry and cboCity in file default.aspx

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Text;
    using System.Data.SqlClient;
    using System.Configuration;

      protected void cboCountry_TextChanged(object sender, EventArgs e)
            {
                SqlCommand cmd = new SqlCommand("SELECT * FROM [Country] where country='" + cboCountry.SelectedValue + "'", new SqlConnection(ConfigurationManager.AppSettings["ConString"]));

                cmd.Connection.Open();   <==== ERROR HERE

                SqlDataReader ddlValues;
                ddlValues = cmd.ExecuteReader();

                cboCity.DataSource = ddlValues;
                cboCity.DataValueField = "City";
                cboCity.DataTextField = "City";
                cboCity.DataBind();

                cmd.Connection.Close();
                cmd.Connection.Dispose();
            }

     

    Friday, August 27, 2010 7:18 AM

Answers

  • Hi,

    This forum is for WF4 only, ASP.NET forum: http://forums.asp.net is the right place for your question.

    Thanks
    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support. My Blog:http://xhinker.com
    Tuesday, August 31, 2010 7:50 AM
    Moderator

All replies