A
Axel Dahmen
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
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