Originally Posted by
Daniil
Hi,
The @Baidaly's example works fine for me with Ext.NET v2.1.1 release, but it would be better to do it like this:
MyCombo.SelectedItems.Add(new Ext.Net.ListItem() { Value = "1" });
Please provide your test case.
Maybe, your Values are integers, aren't? If so, please try this:
MyCombo.SelectedItems.Add(new Ext.Net.ListItem() { Value = 1 });
or
MyCombo.SelectedItems.Add(new Ext.Net.ListItem(1));
It doesnt work, I tried your examples and it works, but I used a store to bind the data, and I am still can not select items..
this is my example:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<%@ 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">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager runat="server" />
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="id" />
<ext:ModelField Name="nombre" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
<ext:MultiCombo ID="MyCombo" runat="server" Width="260" StoreID="Store1" ValueField="id" DisplayField="nombre">
</ext:MultiCombo>
</div>
</form>
</body>
</html>
and this is the page load
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
Store1.DataSource = new object[]
{
new object [] {1, "ana"},
new object [] {2, "juan"},
new object [] {3, "maria"}
};
Store1.DataBind();
MyCombo.SelectedItems.Add(new Ext.Net.ListItem("2"));
//MyCombo.SelectedItems.Add(new Ext.Net.ListItem(2)); doesnt work it needs a string
}
}