这是在我的用户控制
<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>
这就是我将此控件添加到占位符的方式
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();
这就是单击按钮时我试图获取控件的方式
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;
}
}
但是代码显示 0 count.IT 甚至没有进入循环。如何获取动态添加的用户控件的值?
谢谢