Mar 11, 2010, 2:34 AM
[CLOSED] Set the Selected Items in MultiSelect
Hi,
In the sample below when i click thetestSelect button the ComapnyId i have passed selectedCompany = "2,4"; is not selected...Hoe to highlight these selected company value...
In the sample below when i click thetestSelect button the ComapnyId i have passed selectedCompany = "2,4"; is not selected...Hoe to highlight these selected company value...
<table cellpadding="0" cellspacing="0">
<tr>
<td>
Company
</td>
<td>
<ext:Store ID="clstoCompany" runat="server">
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name="CID" />
<ext:RecordField Name="Name" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:MultiSelect ID="cllstComapny" runat="server" DisplayField="Name" ValueField="CID"
StoreID="clstoCompany" KeepSelectiononclick="WithCtrlKey" Width="150" Height="100">
</ext:MultiSelect>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<ext:Button ID="climbMultiSelect" Text="TestMultiSelect" runat="server">
<AjaxEvents>
<Click OnEvent="climbMultiSelect_Click" />
</AjaxEvents>
</ext:Button>
</td>
</tr>
</table>
public partial class UPload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindValues();
}
}
private void BindValues()
{
DataTable dtCompany = new DataTable();
dtCompany.Columns.Add("CID", Type.GetType("System.String"));
dtCompany.Columns.Add("Name", Type.GetType("System.String"));
dtCompany.Rows.Add("1", "EGAR");
dtCompany.Rows.Add("2", "HDFC");
dtCompany.Rows.Add("3", "IBM");
dtCompany.Rows.Add("4", "TCS");
dtCompany.Rows.Add("5", "Western Valley");
clstoCompany.DataSource = dtCompany;
clstoCompany.DataBind();
}
protected void climbMultiSelect_Click(object sender, AjaxEventArgs e)
{
string selectedCompany = "2,4";
SelectMultiList(cllstComapny, selectedCompany);
}
public void SelectMultiList(Coolite.Ext.Web.MultiSelect listBox, string DbValues)
{
string[] arrlst = DbValues.Split(',');
foreach (string id in arrlst)
{
if (!string.IsNullOrEmpty(id))
{
listBox.SelectedItems.Add(new Coolite.Ext.Web.SelectedListItem() { Value = id.ToString() });
}
}
}
}