Jan 21, 2011, 1:13 PM
[CLOSED] Dynamcally created Combox and its Dynamic Store
Hi, I have the following code to dynamically create a combobox with dynamic store. But getting error as "The Control 'Parameter' could not find the StoreID of 'Store1'." How should i modify this code to make it work? Thanks :)
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
public class Vani {
public Vani(string a, string b)
{
this.VALUE = a;
this.VALUE2 = b;
}
public string VALUE
{ get; set; }
public string VALUE2
{ get; set; }
}
protected void Page_Load(object sender, EventArgs e)
{
FormLayout schemaFL = new FormLayout();
schemaFL.ID = "FormPanel1";
Anchor a = new Anchor();
a.Horizontal = "95%";
JsonReader ar = new JsonReader();
RecordField rf = new RecordField("VALUE", RecordFieldType.String);
RecordField rf2 = new RecordField("VALUE2", RecordFieldType.String);
ar.Fields.Add(rf);
ar.Fields.Add(rf2);
Store myStore = new Store();
myStore.ID = "Store1";
myStore.Reader.Add(ar);
myStore.DataSource = new List<Vani> { new Vani("1", "1"), new Vani("2", "2") };
this.form1.Controls.AddAt(0, myStore);
myStore.DataBind();
schemaFL.Anchors.Add(a);
Panel1.Items.Add(schemaFL);
new Ext.Net.ComboBox()
{
ID = "Parameter",
FieldLabel = "Test",
AnchorHorizontal = "95%",
StoreID = "Store1",
ValueField = "VALUE",
DisplayField = "VALUE",
}.Render("FormPanel1", RenderMode.AddTo);
// parametersID = (i == 0 ? "Parameter" + i : parametersID + "^" + "Parameter" + i);
// a.Items.Add(grid);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ScriptManager1" runat="server"/>
<ext:Panel runat="server" ID="Panel1" Width="504" Height="450" Title="DOCUMENT" Icon="BookAddresses">
</ext:Panel>
</form>
</body>
</html>
Last edited by Daniil; Jan 26, 2011 at 8:24 AM.
Reason: [CLOSED]