Ext.Net:radiogruop,请选择单选按钮取决于inputValue的其(Ext.Net:

2019-11-02 05:39发布

我有这样一个radiogruop。

<ext:RadioGroup ID="rdyIsAktifmi" runat="server" FieldLabel="Aktifmi" Width="150" 
    Flex="1">
 <Items>
  <ext:Radio ID="Radio4" runat="server" BoxLabel="pasif" InputValue="0" />
   <ext:Radio ID="Radio5"  runat="server" BoxLabel="aktif" InputValue="1" />
  </Items>
</ext:RadioGroup>

我保存这样的cheched输入值,

rdyIsAktifmi.CheckedItems[0].InputValue //0 or one depents on cheched item

然而从代码绑定它落后时我失败了。

我tryed这一个:

 rdyIsAktifmi.CheckedItems[0].Values = employee_obj.IsAktif;(this come from database as integer value)

我也试过这一个:

rdyIsAktifmi.CheckedItems[0].Set("rdyIsAktifmi", employee_obj.IsAktif);

我怎么可以在其选择inputValue的单选depents。

**我正好找methot这样的事情。

rdyIsAktifmi.CheckedItem.InputValue = employee_obj.IsAktif;

谢谢 。

Answer 1:

我想实现这种方式。

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<%@ Import Namespace="System.Linq" %>

<script runat="server">
    protected void Set0(object sender, DirectEventArgs e)
    {
        Radio r = this.RadioGroup1.Items.Cast<Radio>().First<Radio>(item => item.InputValue == "0");
        r.Checked = true;
    }

    protected void Set1(object sender, DirectEventArgs e)
    {
        Radio r = this.RadioGroup1.Items.Cast<Radio>().First<Radio>(item => item.InputValue == "1");
        r.Checked = true;
    }
</script>

<!DOCTYPE html>
<html>
<head runat="server">
    <title>Ext.NET v2 Example</title>
</head>
<body>
    <form runat="server">
        <ext:ResourceManager runat="server" />

        <ext:RadioGroup ID="RadioGroup1" runat="server" ColumnsNumber="1">
            <Items>
                <ext:Radio ID="Radio1" runat="server" BoxLabel="off" InputValue="0" />
                <ext:Radio ID="Radio2" runat="server" BoxLabel="on" InputValue="1" />
            </Items>
        </ext:RadioGroup>

        <ext:Button runat="server" Text="Set 0" OnDirectClick="Set0" />
        <ext:Button runat="server" Text="Set 1" OnDirectClick="Set1" />
    </form>
</body>
</html>


文章来源: Ext.Net: radiogruop ,make selected radiobutton depend on its InputValue