Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何生成;一旦选中“更改”;控制;复选框“;关于一个;RadCombobox";?_C#_Telerik_Dom Events_Radcombobox_Rad Controls - Fatal编程技术网

C# 如何生成;一旦选中“更改”;控制;复选框“;关于一个;RadCombobox";?

C# 如何生成;一旦选中“更改”;控制;复选框“;关于一个;RadCombobox";?,c#,telerik,dom-events,radcombobox,rad-controls,C#,Telerik,Dom Events,Radcombobox,Rad Controls,我遇到了在radCombobox中为控件“checkBox”实现简单事件“OnCheckedChanged”的困难。 我在网上找到了许多用Javascript编写事件的例子,但从未用C#编写过!为什么?是否无法在C#中生成此事件 以下是我的例子: <telerik:RadComboBox ID="RadComboBoxSelectedEntity" runat="server" AutoPostBack="false" EnableCheckAllItemsCheckBox="false"

我遇到了在radCombobox中为控件“checkBox”实现简单事件“OnCheckedChanged”的困难。 我在网上找到了许多用Javascript编写事件的例子,但从未用C#编写过!为什么?是否无法在C#中生成此事件

以下是我的例子:

<telerik:RadComboBox ID="RadComboBoxSelectedEntity" runat="server" AutoPostBack="false" EnableCheckAllItemsCheckBox="false" EmptyMessage="Tous" CheckedItemsTexts="DisplayAllInInput" CheckBoxes="true" width="300px"  
AllowCustomText="true" DataTextField="name" DataValueField="name"  HighlightTemplatedItems="true">  
<ItemTemplate> 
<asp:CheckBox runat="server" ID="CheckBox"    Text='<%# DataBinder.Eval(Container, "Text") %>' OnCheckedChanged="checkedChangeCombobox" AutoPostBack="true" />  
<asp:Label ID="lblSearchRef" runat="server" Text='<%# DataBinder.Eval(Container, "Text") %>' Visible="true" /> 
</ItemTemplate> 
<CollapseAnimation Duration="200" Type="OutQuint" />
</telerik:RadComboBox>

但不工作…

您需要在组合框的ItemDataBound事件中指定复选框事件处理程序,如下所示:

private void RadComboBoxSelectedEntity_ItemDataBound(object sender, Telerik.Web.UI.RadComboBoxItemEventArgs e)
{
    ((CheckBox)e.Item.FindControl("CheckBox")).CheckedChanged += checkedChangeCombobox;
}
protected void checkedChangeCombobox(object sender, EventArgs e)
{

     CheckBox myCheckBoxes = sender as CheckBox;
     string textChk = myCheckBoxes.Text;

}
private void RadComboBoxSelectedEntity_ItemDataBound(object sender, Telerik.Web.UI.RadComboBoxItemEventArgs e)
{
    ((CheckBox)e.Item.FindControl("CheckBox")).CheckedChanged += checkedChangeCombobox;
}