Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Problem in the UpdatePanel

$
0
0

I have code to generate check box list dynamically according to some conditions, If check box selected  will be disabled vs.
After that will add this check box list control to placeholder in update panel,

Problem doesn't occur at the first time but when i update the criteria to add or remove from check box list , some check boxes disabled but not selected

ASPX Code

  <asp:TextBox AutoPostBack="true" ID="txtCount" runat="server" OnTextChanged="txtCount_TextChanged">0</asp:TextBox>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
                        <asp:PlaceHolder runat="server" ID="ph"></asp:PlaceHolder>
        </ContentTemplate>
    </asp:UpdatePanel>



C# Code

 protected void Page_Load(object sender, EventArgs e)
    {
        CheckBoxList ckb = new CheckBoxList();
        int maxCount = int.Parse(txtCount.Text);

        for (int i = 0; i < maxCount; i++)
        {
            ListItem li = new ListItem();
            li.Text = "CheckBox " + i.ToString();

            bool selected = (i % 2 == 0);

            li.Selected = selected;
            li.Enabled = !selected;

            ckb.Items.Add(li);
        }
        ph.Controls.Add(ckb);

    }
  
    protected void txtCount_TextChanged(object sender, EventArgs e)
    {

    }




Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>