0

我有一个像这样的无线电组。

<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

但是,当从后面的代码绑定它时,我失败了。

我试过这个:

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

我也试过这个:

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

我如何选择单选按钮取决于它的 InputValue。

**我到底在寻找这样的方法。

rdyIsAktifmi.CheckedItem.InputValue=employee_obj.IsAktif;

谢谢你 。

4

1 回答 1

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>
于 2013-06-26T05:56:22.653 回答