Jul 13, 2012, 3:00 PM
[CLOSED] Creating Combobox + Store in CodeBehind
Hi,
I've been looking this over and over again for way too long, what am I doing wrong here? It looks like combobox has 3 items in it, but it doesn't display them.
I've been looking this over and over again for way too long, what am I doing wrong here? It looks like combobox has 3 items in it, but it doesn't display them.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm13.aspx.cs" Inherits="WebApplication1.WebForm13" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
var cb = new ComboBox
{
ID = "cb",
AllowBlank = true,
FieldLabel = "test"
};
Dictionary<int, string> items = new Dictionary<int, string>();
items.Add(1, "test1");
items.Add(2, "test2");
items.Add(3, "test3");
JsonReader jr = new JsonReader() { IDProperty = "Key" };
jr.Fields.Add("Key", RecordFieldType.Int);
jr.Fields.Add("Value", RecordFieldType.String);
Store s = new Store();
s.Reader.Add(jr);
cb.Store.Add(s);
s.DataSource = items;
s.DataBind();
cb.SelectedItem.Value = "2";
Window1.Items.Add(cb);
Window1.Render();
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Window ID="Window1" runat="server" Collapsible="true" Height="185" Icon="Application" Padding="20" Title="Title" Width="350" />
</body>
</html>
thanks in advance!
Last edited by Daniil; Jul 13, 2012 at 7:21 PM.
Reason: [CLOSED]