Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1070
Creating a WebCombo in a cell
posted

 I'm using the following code to create a WebCombo in a cell of my grid and it's not working. Nothing is displayed in the cell when editing. I think the only difference between my code and the example from the docs is that my combo is created in code instead of being defined on the aspx page. Here is my code, does anyone know why this doesn't work?

void employeeGrid_InitializeLayout(object sender, LayoutEventArgs e)
    {
        WebCombo crewTypeList = new WebCombo();
        crewTypeList.DataTextField = CrewTypeFields.CrewType.Name;
        crewTypeList.DataValueField = CrewTypeFields.CrewTypeId.Name;
        crewTypeList.DataSource = ServiceManager.GetEmployeeManager().GetCrewTypes();
        crewTypeList.DataBind();

        e.Layout.Bands[0].Columns.FromKey("CrewType").EditorControlID = crewTypeList.UniqueID;
        e.Layout.Bands[0].Columns.FromKey("CrewType").ValueList.DisplayStyle = ValueListDisplayStyle.DisplayText;
    }

Parents
  • 45049
    posted

    My first impression:  your WebCombo isn't being added to your page, and thus doesn't exist on the client.  Try adding the following line after you instantiate the control:

    this.Form1.Controls.Add(crewTypeList);

    You could also add it to the Controls collection of any container control on your page.  Don't just add it to "this.Page.Controls" - it will end up outside the <form> element, and as an ASP.NET control it must be inside a form element.

Reply Children