i am trying to create a visual webpart in a sandbox solution. i added a dropdownlist named ProjectClient in the ascx page and wrote a function to bind the dropdown in codebehind. but am getting this error as "The name 'ProjectClient' does not exist in the current context". I checked the ascx.g.cs page and the control id is correct there. please help me to fix this.
ascx page:
<div class="col-lg-1">
<asp:Label ID="pClient" runat="server" Text='<%#Eval("Client") %>' />
<asp:DropDownList ID="ProjectClient" runat="server" CssClass="ddclient" Visible="false"></asp:DropDownList>
</div>
code behind file:
public void BindDropDown()
{
ProjectClient.Items.Clear();
if (listToBind != null)
{
ProjectClient.DataSource = listToBind;
ProjectClient.DataTextField = textField;
ProjectClient.DataValueField = valueField;
ProjectClient.DataBind();
}
ProjectClient.Items.Insert(0, new ListItem("-Select-", ""));
}
ascx.g.cs page:
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
[GeneratedCodeAttribute("Microsoft.VisualStudio.SharePoint.ProjectExtensions.CodeGenerators.SharePointWebP" +
"artCodeGenerator", "12.0.0.0")]
private global::System.Web.UI.WebControls.DropDownList @__BuildControl__control7() {
global::System.Web.UI.WebControls.DropDownList @__ctrl;
@__ctrl = new global::System.Web.UI.WebControls.DropDownList();
@__ctrl.TemplateControl = this;
@__ctrl.ApplyStyleSheetSkin(this.Page);
@__ctrl.ID = "ProjectClient";
@__ctrl.CssClass = "ddclient";
@__ctrl.Visible = false;
return @__ctrl;
}