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