[CLOSED] How to create and load store to combobox in codebehind

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] How to create and load store to combobox in codebehind

    Hi,

    I need to create and load the sotre to combobox in codebehind. I need to do that, because i have a dynamical formpanel (FP), where FP can have textfield and/or combobox.

    This FP can have one of both or many of them, so I need to create and load the store (each store have different data) for each combobox.

    So, how I can do that??.

    I do this in my code, but the FP don't show me anything.


     private void Create()
            {
                    System.Data.DataTable theDataTable = getData(query);
                    int cant = int.Parse(theDataTable.Rows.Count.ToString());
                    if (cant > 0)
                    {                    
                        for (int i = 0; i < cantidad; i++)
                        {
                            System.Data.DataRow theDataRow = getRow();
                            string AtribType = theDataRow["type"].ToString();
                           
                            if (AtribType.Equals(COMBOTYPE))
                            {                            
                                Store str = new Store();
                                str.ID = "Store" + i.ToString();
                                str.Fields.Add(theDataTable.Columns[0].ColumnName);
                                str.Fields.Add(theDataTable.Columns[1].ColumnName, ModelFieldType.String);
                                str.DataSource = theDataTable;
                                str.DataBind();
    
                                FormPanelAtributos.Items.Add(new ComboBox { FieldLabel = theDataRow["columnA"].ToString(), EnableKeyEvents = true, MsgTarget = MessageTarget.Side, AllowBlank = true, QueryMode = DataLoadMode.Local, StoreID=str.ID, DisplayField = theDataTable.Columns[1].ColumnName, ValueField = theDataTable.Columns[1].ColumnName, EmptyText = "Select...", Name = theDataRow["columnB"].ToString() });
                            }
                            else
                            {
                                FormPanelAtributos.Items.Add(new TextField { FieldLabel = theDataRow["columnA"].ToString(), EnableKeyEvents = true, MsgTarget = MessageTarget.Side, AllowBlank = true });
                            }
                        }
                        FormPanelControls.Render(WindowCtr, RenderMode.AddTo);
                    }
    }
    Best Regards.

    Thanks a lot.
    Last edited by Daniil; Apr 21, 2015 at 6:48 PM. Reason: [CLOSED]
  2. #2
    Hi @opendat2000,

    Do you run that code on initial page load? If so, please remove:
    FormPanelControls.Render(WindowCtr, RenderMode.AddTo);
    Or during a DirectEvent?

    A runnable test case would help us to help you as soon as possible.
  3. #3
    Daniil,

    thanks for your prompt reply.

    No, the code is run when I click on a row in a gridpanel and show the windows with the combobox and/or the textfield.


    Example:

    1.- Run the app.
    2.- Select a item in a treepanel.
    3.- Show data in a gridpanel of the item selected in 2.
    4.- Click in one of data.
    5.- Show the window with a X quantity of combobox and/or textfield.

    The window in the point 5 have a different quantity for combobox and/or textfield, this is because that the item selected in the tree panel, are different for others.

    Thanks a lot.

    Best Regards.
  4. #4
    1.- Run the app.
    Please clarify - what the app should I run?
  5. #5
    Run the App is just a example of the step of how works.


    thanks a lot.
  6. #6
    Ok. I think I need such an app to go through the steps. Could you, please, provide?

Similar Threads

  1. [CLOSED] Creating Combobox + Store in CodeBehind
    By trezv in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 12, 2015, 1:41 PM
  2. [CLOSED] Load combobox's store
    By romeu in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 11, 2013, 1:50 PM
  3. [CLOSED] How to create and load datasource ( Store ) dynamically in MVC
    By pawangyanwali in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 29, 2012, 10:55 AM
  4. Replies: 0
    Last Post: Mar 31, 2012, 9:10 AM
  5. [CLOSED] Create records in store combobox
    By softmachine2011 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 19, 2011, 9:28 AM

Tags for this Thread

Posting Permissions