This is in my user control
<div class=" row-fluid">
<div class="span4" style="overflow: hidden;">
<asp:DropDownList ID="ddlAccountName" runat="server" DataSourceID="ChartOfAccountsforVouchers"
DataTextField="AccountName" DataValueField="ChartOfAccID">
</asp:DropDownList>
<%-- <asp:EntityDataSource ID="ChartOfAccountsforVouchers" runat="server" ConnectionString="name=CnFV1MainModelEntities"
DefaultContainerName="CnFV1MainModelEntities" EnableFlattening="False" EntitySetName="ChartOfAccounts"
Select="it.[ChartOfAccID], it.[AccountName]">
</asp:EntityDataSource>--%>
</div>
<div class="span4">
<asp:TextBox ID="txtValue" MaxLength="10" CssClass="numeric input-block-level" runat="server"></asp:TextBox>
</div>
<div class="span4">
<asp:TextBox ID="txtValueB" MaxLength="10" CssClass="numeric input-block-level" runat="server"></asp:TextBox>
</div>
And this is how i am adding this control to a placeholder
int count = Convert.ToInt32(Session["AddedRows"]);
++count;
for (int i = 0; i < count; i++)
{
// Add the usercontrol dynamically
Control webUserControl = (Control)Page.LoadControl("ctrlEntryRows.ascx");
placeRows.Controls.Add(webUserControl);
}
Session["AddedRows"] = count.ToString();
And this is how on a button click i am trying to get the controls
if (placeRows.Controls.Count > 0)
{
foreach (Control ctrl in placeRows.Controls)
{
TextBox txt = (TextBox)placeRows.FindControl("txtValue");
TextBox txtB = (TextBox)placeRows.FindControl("txtValueB");
string message = txt.Text + txtB.Text;
}
}
But the code shows 0 count.IT doesn't even get in the loop. How do i get the values of my dynamically added user controls?
Thank you