your code should be like this, i assume that DisplayvalueField and
DisplayTextField is set through properties. if it is not then


 public partial class _Default : System.Web.UI.Page
 {
     protected void Page_Load(object sender, EventArgs e)
     {
if (! IsPostBack)
{
         SqlConnection con = new SqlConnection("Persist Security
 Info=False;Integrated Security=SSPI;server=CODENAME;database=try");
         SqlCommand com = new SqlCommand("Select CountryId,CountryName
 from country", con);
         SqlDataAdapter da = new SqlDataAdapter(com);
      DataSet ds = new DataSet();
      da.Fill(ds);
      countryddl.DataSource = ds;
      countryddl.DataBind();
}
 }



 protected void countryddl_SelectedIndexChanged(object sender,
 EventArgs e)
     {
         int sel_val = Convert.ToInt32(countryddl.SelectedItem.Value);
         Response.Write(sel_val);

 }

Reply via email to