Friday, October 12, 2007

CheckBox in RadComboBox(MultiSelect RadComboBox)

function stopPropagation(e,CheckBoxControl,ComboBoxControl)
{
// Calling the CheckChanged function (parameter: CheckBox Control)
CheckChanged(CheckBoxControl,ComboBoxControl);

// To keep the dropdown open
e.cancelBubble = true;
if (e.stopPropagation)
{
e.stopPropagation();
}
}

// To set the ComboBox Text with the Checked ComboBox Text
function CheckChanged(CheckBoxControl,ComboBoxControl)
{
var combo = ~~%=RadComboBox1.ClientID %~~~;
var str="";
for(i=0; i~~combo.Items.length; i++)
{
var controlid="RadComboBox1_c"+eval(i) + "_CheckBox";
var control=document.getElementById(controlid);
if(control.checked)
{
str+=combo.Items[i].Text+";"
}
else
continue;
}
combo.SetText(str);
}



In the RadComboBox ItemTemplate

~~ItemTemplate~~~
~~asp:CheckBox runat="server" ID="CheckBox" onclick="stopPropagation(event,this,'RadComboBox1');"
Text='~~%# Eval("Text") %~~~' /~~~ ~~/ItemTemplate~~~

Please replace "~~" with less than symbol and replace "~~~" with greater than symbol