0
Answer

How to retrieve dynamically created drop down list value ?

pradeepa meiyappan

pradeepa meiyappan

10y
872
1
 How to retrieve value from dynamically created dropdownlist and store it into sqlserver 2008?
 
In my form i had name as textbox,jobtype as dropdownlist bind from database,based on that i dynamically created dropdownlist for skills and level. 
 After Clicking Submit Button, how to store that value into sql database.

My Table Name: ProfileSkill

Fields: Name, Jobtype, skills, level
 
My Code for Dynamic Dropdown Creation: 
 
void skillbind()
{
cmd.CommandText = "select Skill from jobtype where jobname='" + DDLJType.SelectedItem.Text + "' ";
cmd.Connection = con;
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
DropDownList ddlskill = new DropDownList();
ddlskill.Items.Add( dr.GetValue(0).ToString());
PlaceHolder1.Controls.Add(ddlskill);
ddlskill.Items.Insert(0, "------SELECT------");
ddlskill.Width = 200 ;
PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));
DropDownList ddllevel = new DropDownList();
ddllevel.Items.Add("Beginer");
ddllevel.Items.Add("Intermediate");
ddllevel.Items.Add("Expert");
PlaceHolder2.Controls.Add(ddllevel);
ddllevel.Items.Insert(0, "-----SELECT----");
ddllevel.Width = 200;
PlaceHolder2.Controls.Add(new LiteralControl("<br/>"));
}
dr.Close();
con.Close();
}
}