[CLOSED] Why i get checkboxgroup.CheckedItems.Count Always 0 ?

  1. #1

    [CLOSED] Why i get checkboxgroup.CheckedItems.Count Always 0 ?

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Data" %> 
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                for (int i = 0; i <5; i++)
                {
                    
                 Ext.Net.Checkbox cbo = new Ext.Net.Checkbox();
                cbo.BoxLabel = "item "+i.ToString();
                cbo.AnchorHorizontal = "100%";
    
                cbo.Checked = true;
    
                cbo.InputValue = i.ToString();
                cbg1.Items.Add(cbo);   
                }
                
    
            }
        }
    
        protected void GetCount(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("Count", this.cbg1.CheckedItems.Count).Show();
        }
    </script>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
                <ext:CheckboxGroup ID="cbg1" runat="server" ColumnsNumber="1" X="5" Y="5" >
                    <Items>
                      <%--  <ext:Checkbox ID="Checkbox4" runat="server" BoxLabel="Item 1" />
                        <ext:Checkbox ID="Checkbox5" runat="server" BoxLabel="Item 2" Checked="true" />
                        <ext:Checkbox ID="Checkbox6" runat="server" BoxLabel="Item 3" />
                        <ext:Checkbox ID="Checkbox7" runat="server" BoxLabel="Item 4" />
                        <ext:Checkbox ID="Checkbox8" runat="server" BoxLabel="Item 5" />--%>
                    </Items>
                </ext:CheckboxGroup>
            <ext:Button ID="Button1" runat="server" Text="Show .Count" OnDirectClick="GetCount" />
        </form>
    </body>
    </html>
    Last edited by Daniil; Apr 23, 2012 at 9:43 AM. Reason: [CLOSED]
  2. #2
    Hi,

    The dynamically created Checkboxes should be recreated during DirectEvent.

    Example
    protected void Page_Load(object sender, EventArgs e)
    {
        for (int i = 0; i < 5; i++)
        {
            Ext.Net.Checkbox cbo = new Ext.Net.Checkbox();
            cbo.BoxLabel = "item " + i.ToString();
    
            cbo.InputValue = i.ToString();
            cbg1.Items.Add(cbo);
    
            if (!X.IsAjaxRequest)
            {
                cbo.Checked = true;
            }
        }
    }
  3. #3
    If you'd like to avoid re-creating, you can use one of these options:
    http://forums.ext.net/showthread.php...ll=1#post80063

Similar Threads

  1. RadioGroup.CheckedItems.Count == 0 v1.2.0
    By chearner in forum 1.x Help
    Replies: 4
    Last Post: Dec 09, 2011, 2:23 PM
  2. How to Get the RadioGroup.CheckedItems?
    By sk2276699 in forum 1.x Help
    Replies: 1
    Last Post: Jun 28, 2011, 3:22 AM
  3. Replies: 9
    Last Post: Jun 15, 2011, 7:01 AM
  4. Replies: 1
    Last Post: Jun 04, 2010, 5:21 PM
  5. [CLOSED] [1.0] RadioGroup CheckedItems empty
    By danielg in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 28, 2010, 5:12 PM

Tags for this Thread

Posting Permissions