public void fillddl() { SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]); try { string sql = "select qualificationId,qualificationName from UserQualification"; DataSet ds = new DataSet(); //SqlCommand cmd = new SqlCommand(); SqlDataAdapter da = new SqlDataAdapter(sql, con); da.Fill(ds); DDDLQualification.DataSource = ds; DDDLQualification.DataTextField = "qualificationName"; DDDLQualification.DataValueField = "qualificationId"; DDDLQualification.DataBind(); DDDLQualification.Items.Add("Custom"); DDDLQualification.Items.Insert(0, new ListItem("--Select--", "0")); DDDLQualification.SelectedIndex = 0; //DDDLQualification.DataSource = ds.Tables[0]; //if (ds.Tables[0].Rows.Count > 0) //{ // DDDLQualification.DataTextField = "qualificationName"; // DDDLQualification.DataValueField = "qualificationId"; //} //DDDLQualification.DataBind(); //DDDLQualification.Items.Add("Add New"); //DDDLQualification.Items.Add("---Select---"); //DDDLQualification.SelectedIndex = DDDLQualification.Items.Count - 1; } catch (Exception ex) { throw ex; } finally { con.Open(); } }
public void txtChange(DropDownList ddl, TextBox tx) { string str = "insert into UserQualification(qualificationName)values('" + DDDLQualification.SelectedValue + "')"; int row = cc.ExecuteNonQuery(str); string st = "select qualificationId,qualificationName from UserQualification "; ds = cc.ExecuteDataset(st); DDDLQualification.DataSource = ds; DDDLQualification.DataTextField = "qualificationName"; DDDLQualification.DataValueField = "qualificationId"; DDDLQualification.DataBind(); DDDLQualification.Items.Insert(0, new ListItem("Select", "0")); DDDLQualification.SelectedIndex = 0; ddl.Visible = true; tx.Visible = false; }
private void Bind_Qualification() { string sql = "select qualificationId,qualificationName from UserQualification"; DataSet ds = cc.ExecuteDataset(sql); //SqlDataAdapter da = new SqlDataAdapter(str, con); //da.Fill(ds); DDDLQualification.DataSource = ds.Tables[0]; if (ds.Tables[0].Rows.Count > 0) { //ddl.DataTextField = "Name"; DDDLQualification.DataValueField = "qualificationId"; DDDLQualification.DataTextField = "qualificationName"; } DDDLQualification.DataBind(); DDDLQualification.Items.Add("Add New"); DDDLQualification.Items.Add("---Select---"); DDDLQualification.SelectedIndex = DDDLQualification.Items.Count - 1; DDDLQualification.Items[DDDLQualification.Items.Count - 1].Value = ""; //DDDLQualification.DataSource = ds.Tables[0]; //DDDLQualification.DataTextField = "qualificationName"; //DDDLQualification.DataValueField = "qualificationId"; //DDDLQualification.DataBind(); //DDDLQualification.Items.Add("--Select--"); //DDDLQualification.SelectedIndex = DDDLQualification.Items.Count - 1; string sql2 = "select brduniId,brduniName from UserBoardUniversity"; DataSet dset = cc.ExecuteDataset(sql2); ddlUniversity.DataSource = dset.Tables[0]; ddlUniversity.DataTextField = "brduniName"; ddlUniversity.DataValueField = "brduniId"; ddlUniversity.DataBind(); ddlUniversity.Items.Add("--Select--"); ddlUniversity.SelectedIndex = ddlUniversity.Items.Count - 1; }