TAGS :Viewed: 4 - Published at: a few seconds ago

[ How to assign Page.FindControl Dropdownlist to array from N-Tier as Data Source ]

Here is my code. The issue is I can't figure out how to access the control in the grid view. So, I am trying to use Page.findControl but I can't seem to find a online solution on how to get control to work in the code behind page to identifying the control and then adding it already to my defined data source.

WorkShopClassBusiness WCB = new WorkShopClassBusiness();
List<WorkShopClass> Ls = WCB.GetWorkClass();

Page.FindControl("DropDownList5").DataSource = Ls;
Page.FindControl("DropDownList5").DataValueField = "WorkShopClassID";
Page.FindControl("DropDownList5").DataTextField = "Name";
Page.FindControl("DropDownList5").DataBind();

Answer 1


For the gridview, you have to get to the rows and cells level:

var ddl = grid.Rows[1].Cells[1].FindControl("DropDownList5")
ddl.DataSource = Ls;
.
.