PDA

View Full Version : [CLOSED] couldn't create dynamically added control



gumush75
Mar 08, 2014, 6:58 AM
I could not add controls dynamically. What might be problem ?
Aspx code:

<ext:Panel ID="Panel3" runat="server" Header="false">
<Items>
<ext:FormPanel ID="FormPanel2"
runat="server"
Header="false"
Frame="true"
DefaultAnchor="100%"
BodyPadding="5">

<FieldDefaults LabelAlign="Right" LabelWidth="90" MsgTarget="Qtip" />
<Items>
<ext:FieldSet ID="FieldSet6"
runat="server"
Title="Teklif mi Sipariş mi ?"
Layout="AnchorLayout"
DefaultAnchor="100%">
<Items>
<ext:FieldContainer ID="FieldContainer2"
runat="server"
FieldLabel="?r?n Kodu/Adı"
Layout="HBoxLayout"
CombineErrors="true">
<Items>
<ext:ComboBox runat="server" ID="cmbUrunKodu" AllowBlank="false"
HideBaseTrigger="true" EnableKeyEvents="true" DisplayField="marka" ValueField="marka"
Width="570" PageSize="10"
MinChars="0" OnDirectSelect="cmbUrunKodu_DirectSelect"
TriggerAction="Query" StoreID="StoreStok">
<ListConfig LoadingText="Y?kleniyor...">
<ItemTpl ID="ItemTpl1" runat="server">
<Html>
<div class="search-item">
<h3><span>{id}</span>{marka}</h3>
{uretimYeri}
</div>
</Html>
</ItemTpl>
</ListConfig>
<Listeners>
<Change Fn="UrunKoduEntered"></Change>
</Listeners>
</ext:ComboBox>
</Items>
</ext:FieldContainer>
</Items>
</ext:FieldSet>

<ext:FieldSet ID="FieldSet7"
runat="server"
Title="Se?enekler"
Layout="AnchorLayout" AutoRender="true"
DefaultAnchor="100%">
<Items>
<ext:TextField FieldLabel="deneme" runat="server"></ext:TextField>
</Items>
</ext:FieldSet>
</Items>
</ext:FormPanel>
</Items>
</ext:Panel>

cs code:


/// <summary>
/// Se?iminden sonra ekranda kontroller create edilir.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void cmbUrunKodu_DirectSelect(object sender, DirectEventArgs e)
{
try
{
SiparisManager sm = new SiparisManager();
DataTable dt = sm.GET_Selections_Sil();
this.FieldSet7.Items.Clear();
foreach (DataRow dr in dt.Rows)
{
string selectName = dr[0].ToString();

DataTable dtOptions = sm.GET_SelectionsByName_Sil(selectName);

ComboBox cmb = new ComboBox();
//cmb.Tag = selectName;
cmb.ID = Guid.NewGuid().ToString();
cmb.FieldLabel = selectName;
foreach (DataRow drOpt in dtOptions.Rows)
{
cmb.Items.Add(new Ext.Net.ListItem(drOpt[0].ToString(), drOpt[1].ToString()));
}
this.FieldSet7.Items.Add(cmb);
this.FieldSet7.Render(cmb.ClientID, RenderMode.AddTo);
}
}
catch (Exception ex)
{
string a = ex.Message;
}
}

Vladimir
Mar 10, 2014, 8:55 AM
Please always post runnable samples

Try to replace the following lines


this.FieldSet7.Items.Add(cmb);
this.FieldSet7.Render(cmb.ClientID, RenderMode.AddTo);


by


this.FieldSet7.Items.Add(cmb);
cmb.Render();