Controls in UserControl: why empty?

Discussion in 'ASP .Net' started by Axel Dahmen, Jun 29, 2003.

  1. Axel Dahmen

    Axel Dahmen Guest

    Hi,

    I've created a UserControl containing an <asp:Repeater> control, containing an <asp:Checkbox> control:

    /-------------------------
    <asp:Repeater Runat="server" ID="propRpt">
    <ItemTemplate>
    <tr><td>
    <asp:CheckBox Runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Description")%>' TextAlign="Right"/>
    <asp:Literal Runat="server" Visible="False" Text='<%#DataBinder.Eval(Container.DataItem,"ID")%>'/>
    </td></tr>
    </ItemTemplate>
    </asp:Repeater>
    \-------------------------


    On Page_Load (!PostBack), the <asp:Repeater> gets filled by database:

    /-------------------------
    propRpt.DataSource=...;
    propRpt.DataBind();
    \-------------------------


    On PostBack I want to iterate through the checkboxes to retrieve their values:

    /-------------------------
    foreach (RepeaterItem ri in propRpt.Controls)
    {
    if (((CheckBox)ri.Controls[1]).Checked)
    ret[idx++]=Convert.ToInt16(((TextBox)ri.Controls[2]).Text);
    }
    \-------------------------

    However, "(CheckBox)...Checked" always yields false!?! Can someone please enlighten me on the reason? What did I do wrong?

    Even more strange: If the page is displayed on Postback, the checked Checkboxes are actually displayed as being checked...


    I'm having the same problem with a second UserControl of mine which is resembling the first but uses Textboxes instead of the Checkbox. I can't evaluate their values, too. Nonetheless, after PostBack they show the values I've entered. So it's not kind of an "EnableViewState problem".

    TIA,
    Axel Dahmen
    Axel Dahmen, Jun 29, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. huobazi
    Replies:
    1
    Views:
    682
    David Waz...
    Jul 3, 2003
  2. Rajesh Tiwari

    Can we use a usercontrol inside a usercontrol

    Rajesh Tiwari, Aug 12, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    409
    Rajesh Tiwari
    Aug 12, 2003
  3. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    878
    Mark Rae
    Dec 21, 2006
  4. Mr. SweatyFinger

    why why why usercontrol

    Mr. SweatyFinger, Nov 29, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    324
    Steve B.
    Nov 29, 2006
  5. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,816
    Smokey Grindel
    Dec 2, 2006
Loading...

Share This Page