Ext.Net: radiogruop ,make selected radiobutton depend on its InputValue

懵懂的女人 提交于 2019-12-25 01:18:33

问题


I have a radiogruop like this.

<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>

I save the cheched input value like this,

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

however when binding it from code behind I failed.

I tryed this one :

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

I also tried this one :

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

how I can select radiobutton depents on its InputValue.

**what I exactly looking for a methot something like this.

rdyIsAktifmi.CheckedItem.InputValue=employee_obj.IsAktif;

thank you .


回答1:


I would achieve it this way.

<%@ 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>


来源:https://stackoverflow.com/questions/17259637/ext-net-radiogruop-make-selected-radiobutton-depend-on-its-inputvalue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!