Mar 09, 2015, 11:57 AM
[CLOSED] Simple select Dynamic Combo
Doing something wrong. Not sure what. Want to select the item with the 90720 value.
<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
createKeuzeLijst().AddTo(fpTest);
preselectValue();
}
}
public ComboBox createKeuzeLijst()
{
const int nVeldID = 1;
const string cVeldNaam = "TestField";
const string cVeldOmschrijving = "TestDescription";
ComboBox cb = new ComboBox
{
ID = string.Format("cb{0}", cVeldNaam),
ToolTip = cVeldOmschrijving,
FieldLabel = cVeldNaam,
ValueField = "cItemWaarde",
DisplayField = "cItemText",
AnchorHorizontal = "100%",
EmptyText = "-- maak keuze --"
};
AddItems(cb, nVeldID);
return cb;
}
public void AddItems(ComboBox cb, Int32 nVeldId)
{
Dictionary<String, String> dic = new Dictionary<string, string>();
dic.Add("99999", "99999 - Ford Rent actie auto");
dic.Add("90720", "90720 - Ford Rent ondersteuning");
dic.Add("90750", "90750 - Incentive ondersteuning");
foreach (KeyValuePair<string, string> entry in dic)
{
cb.Items.Add(new Ext.Net.ListItem(entry.Key, entry.Value));
}
}
public void preselectValue()
{
ComboBox cb = X.GetCmp<ComboBox>("cbTestField");
cb.SelectedItems.Add(new Ext.Net.ListItem { Value = "90720", Mode = ParameterMode.Raw });
cb.UpdateSelectedItems();
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Dynamic combo</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:FormPanel runat="server" ID="fpTest" />
</form>
</body>
</html>
Last edited by Daniil; Mar 10, 2015 at 9:56 AM.
Reason: [CLOSED]