I have created dynamic controls on button click and I'm not able to retrieve values of dynamically created controls. I am getting values of dynamic controls inside a panel. pnlDepartment is the Panel ID.
The strDDLValue has only first dropdown values and when it loops for the second time it still takes the first dropdown values and unable to get dynamic control values. Please correct me if I'm making a mistake somewhere.
protected void btnValues_Click(object sender, EventArgs e) { string strDDLValue = string.Empty; foreach (DropDownList ddl in pnlDepartment.Controls.OfType<DropDownList>()) { strDDLValue = ddlName.SelectedItem.Text + "," + ddlLocation.SelectedItem.Text; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)