Hello all,
I'm trying to put a DropDownList in my EditForm, and populate it in the ItemCommand method. Existing codebehind is like this:
My problem is that the FindControl() method isn't actually finding the control. I'm 100% sure everything is named the same, and I've used this method on other types of controls (listBox, Label, Button, etc.) but when I'm using it on the DDL it just fails. Should I be doing this in another method? or is there a way to make it work here?
I'm trying to put a DropDownList in my EditForm, and populate it in the ItemCommand method. Existing codebehind is like this:
GridEditFormItem item = (GridEditFormItem)(e.Item
as
GridDataItem).EditFormItem;
DropDownList ddlTeams = (DropDownList)item.FindControl(
"ddlTeams"
);
ddlTeams.DataSource = GetTeamsDS();
ddlTeams.DataTextField =
"TeamName"
;
ddlTeams.DataValueField =
"TeamName"
;
ddlTeams.DataBind();
My problem is that the FindControl() method isn't actually finding the control. I'm 100% sure everything is named the same, and I've used this method on other types of controls (listBox, Label, Button, etc.) but when I'm using it on the DDL it just fails. Should I be doing this in another method? or is there a way to make it work here?