for (int i = 0; i <= Convert.ToInt16(DropDownList2.SelectedValue); i++) { DropDownList dp = new System.Web.UI.WebControls.DropDownList(); dp.ID = "ClRepList" + i; dp.AutoPostBack = true; dp.Height = 24; dp.Width = 102; dp.DataTextField = "PName"; dp.DataValueField = "PName"; dp.DataSource = return_data_table(); dp.DataBind(); ClientRepInfo.Controls.Add(dp); }
protected void Button1_Click(object sender, EventArgs e) { string[] Path=new string[5]; ContentPlaceHolder MainCont =Page.Master.FindControl("MainContent") as ContentPlaceHolder; for (int k = 0; k <= 4; k++) { Panel Dpanel = (Panel)MainCont.FindControl("ClientRepInfo") as Panel; DropDownList drp = (DropDownList)Dpanel.FindControl("ClRepList" + k); if (drp != null) // if (MainCont.FindControl("ClRepList" + k) != null) { Path[k] = drp.SelectedValue; } }
foreach ( Control ctrl in panel) { if(ctrl is DropDownList) { Path[k] = ctrl .SelectedValue; //let me know if it is giving null value } // }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)