Saber que radio se chequea en RadioGroup (ext.net)

I dinamically add one RadioGroup into a panel (see code below)

ctrl = new Ext.Net.RadioGroup();
ctrl.ID = idPregunta.ToString();
ctrl.EnableViewState = true;
((Ext.Net.RadioGroup)ctrl).GroupName = idPregunta.ToString();
((Ext.Net.RadioGroup)ctrl).FieldLabel = pregunta;
((Ext.Net.RadioGroup)ctrl).Height = 40;
((Ext.Net.RadioGroup)ctrl).LabelAlign = LabelAlign.Top;
((Ext.Net.RadioGroup)ctrl).ColumnsNumber = respuestas.Count;
bool First = true;
int radio=1;
foreach (var r in respuestas)
{
    Ext.Net.Radio rdio = new Radio();
    rdio.BoxLabel = r.ToString();
    rdio.Width = 100;
    rdio.ID = RADIO_ID + radio.ToString();
    if (First)
    {
        rdio.Checked = true;
        First = false;
    }
    radio++;
    ((Ext.Net.RadioGroup)ctrl).Items.Add(rdio);
 }

But when i try to read the checked item in code behind my group doesn't have a item

   p.RespuestaSeleccionada = X.GetCmp<Ext.Net.RadioGroup>(preg.ID).CheckedItems.FirstOrDefault<Ext.Net.Radio>().BoxLabel;

so who i can know the checked item?

Gracias por adelantado

preguntado el 05 de mayo de 13 a las 19:05

2 Respuestas

Really, X.GetCmp() doesn't work as expected. We will investigate. (Investigated. See EDIT below the sample.)

Though, in any way, it would not give access to a Radio's BoxLabel. X.GetCmp<> just retrieve respective values from POST, but a BoxLabel is not a submitable thing. You can get access to a Radio's InputValue (or its client id if InputValue is omitted).

For now, you can retrieve the thing direct from POST.

Ejemplo

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

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

<script runat="server">
    protected void RenderRadioGroup(object sender, DirectEventArgs e)
    {
        RadioGroup rg = new RadioGroup()
        {
            ID = "RadioGroup1",
            GroupName = "RadioGroup1",
            ColumnsNumber = 1,
            Items =
            {
                new Radio() { InputValue = "Radio1", BoxLabel = "Radio1" }, 
                new Radio() { InputValue = "Radio2", BoxLabel = "Radio2" }
            }
        };

        rg.Render(this.Form);
    }

    [DirectMethod]
    public void GetCheckedItems()
    {            
        X.Msg.Alert("GetCheckedItems", Request.Params["RadioGroup1"]).Show();
    }
</script>

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

        <ext:Button runat="server" Text="Render a RadioGroup" OnDirectClick="RenderRadioGroup" />

        <ext:Button runat="server" Text="Get CheckedItems" Handler="App.direct.GetCheckedItems();" />
    </form>
</body>
</html>

EDITAR

Unfortunately, X.GetCmp() can't work. It can work only if populate a created RadioGroup's Items with all its Radio created by X.GetCmp(), but it is too cumbersome. So, getting a value direct from POST looks the only appropriate solution.

contestado el 06 de mayo de 13 a las 12:05

yes, i read the ID with the Request["GroupRadio_ID"], that retrieve me the ID of the selected radio - cristian damian

contestado el 23 de mayo de 17 a las 11:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.