Apr 15, 2015, 1:11 PM
[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.
Thanks a lot.
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]