ancy chacko

ancy chacko

  • NA
  • 71
  • 18.3k

Error in binding dropdownlist in asp.net

Feb 27 2015 9:15 AM

 i want to bind value  in dropdownlist. but i can't insert that data in another table.
 public void Funcdivision()
    {
       // Dpdivisn.Items.Add(new ListItem("--Select --", ""));
       // Dpdivisn.AppendDataBoundItems = true;
        MySqlDataAdapter da = new MySqlDataAdapter("Select distinct Divisions from tbl_divisions", cn);
        DataTable dt = new DataTable();
        da.Fill(dt);
        Dpdivisn.DataSource = dt;
        Dpdivisn.DataValueField = "Divisions";
        Dpdivisn.DataBind();
        Dpdivisn.Items.Insert(0, new ListItem("--Select--", "0"));
        //Dpdivisn.Items.Insert(0, "Select");
    }


 cn.Open();


        string str2 = "insert into tbl_organization values('" + lblempcode.Text + "','" + Dpgroup.SelectedItem.Text + "','" + ddplegal.SelectedItem.Text + "','" + Dpdivisn.SelectedItem.Text + "','" + Dplocation.SelectedItem.Text + "','" + Dpdepartment.SelectedItem.Text + "','" + DropDownList6.SelectedItem.Text + "','" + Dpdesign.SelectedItem.Text + "','" + DpProject.SelectedItem.Text + "','InActive','" + DropDownList7.SelectedItem.Text + "')";
        MySqlCommand Cmd2 = new MySqlCommand(str2, cn);
        Cmd2.ExecuteNonQuery();
        cn.Close();
inserting is not working 

Answers (2)