Ask a Question related to ASP.NET General, Design and Development.
-
Axel Dahmen #1
Controls in UserControl: why empty?
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,"Descr iption")%>' 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 Guest
-
UserControl ViewState with dynamic child controls
I have a custom UserControl where the content is dynamically generated when the containing Page calls a certain method (i.e. DisplayData). The... -
Controls inheriting ListControl will not fire in UserControl
I ran into a problem when building some usercontrols. I am using a dropdownlist and radiobuttonlist and setting the AutoPostBack = "True". I add... -
Event not firing. Adding controls dynamically to UserControl
I am adding controls to the UserControl dynamically and then loading the UserControl Dynamically.But I am facing problem with firing of click event... -
Event not firing.adding dynamic controls to Usercontrol.
I am adding controls to the UserControl dynamically and then loading the UserControl Dynamically.But I am facing problem with firing of click event... -
Use LoadControl to load a usercontrol but the webcontrol in the usercontrol can not AutoPostBack
a uscontrol test.ascx have a dropdownlist web control the dropdownlist's AutoPostBack property is set "true" but when i use...



Reply With Quote

