H
hb
Hi,
I have a page that uses dynamic generated web user control.
On the eupdate.aspx, I get:
===
<asp:table id="tblE" runat="server">
<asp:tablerow id="rE" runat="server">
<asp:tablecell id="cE" runat="server" />
</asp:tablerow>
</asp:table>
<asp:button id="btnUpdate" runat="server" text="Update" />
===
On the eupdate.aspx.cs, I get:
===
protected System.Web.UI.WebControls.Table tblE;
protected System.Web.UI.WebControls.TableRow rE;
protected System.Web.UI.WebControls.TableCell cE;
protected System.Web.UI.WebControls.Button btnUpdate;
private void Page_Load(object sender, System.EventArgs e)
{
cE.Controls.Add(new LiteralControl("<table><tr>"));
for (int i=0;i<10;i++)
{
GofBiz.controls.electricuse eu =
(electricuse)LoadControl("/controls/electricuse.ascx");
//----assign value to eu control----
cE.Controls.Add(new LiteralControl("<tr>"));
cE.Controls.Add(eu);
cE.Controls.Add(new LiteralControl("</tr>"));
eu=null;
}
cE.Controls.Add(new LiteralControl("</table>"));
}
private void btnUpdate_Click(object sender, System.EventArgs e)
{
int n2=cE.Controls.Count;
for(int j=0;j<n2;j++)
{
Response.Write(cE.Controls[j].GetType().Name+"<br>");
}
Response.End();
}
===
But in btnUpdate_Click() event, it finds no control in cE tableCell.
It seems that the controls added to cE only have their live time in
Page_Load(). Would you please tell me how persist the live time
of those dynamic web user control from Page_Load() into btnUpdate_Click() ?
Thank you
hb
I have a page that uses dynamic generated web user control.
On the eupdate.aspx, I get:
===
<asp:table id="tblE" runat="server">
<asp:tablerow id="rE" runat="server">
<asp:tablecell id="cE" runat="server" />
</asp:tablerow>
</asp:table>
<asp:button id="btnUpdate" runat="server" text="Update" />
===
On the eupdate.aspx.cs, I get:
===
protected System.Web.UI.WebControls.Table tblE;
protected System.Web.UI.WebControls.TableRow rE;
protected System.Web.UI.WebControls.TableCell cE;
protected System.Web.UI.WebControls.Button btnUpdate;
private void Page_Load(object sender, System.EventArgs e)
{
cE.Controls.Add(new LiteralControl("<table><tr>"));
for (int i=0;i<10;i++)
{
GofBiz.controls.electricuse eu =
(electricuse)LoadControl("/controls/electricuse.ascx");
//----assign value to eu control----
cE.Controls.Add(new LiteralControl("<tr>"));
cE.Controls.Add(eu);
cE.Controls.Add(new LiteralControl("</tr>"));
eu=null;
}
cE.Controls.Add(new LiteralControl("</table>"));
}
private void btnUpdate_Click(object sender, System.EventArgs e)
{
int n2=cE.Controls.Count;
for(int j=0;j<n2;j++)
{
Response.Write(cE.Controls[j].GetType().Name+"<br>");
}
Response.End();
}
===
But in btnUpdate_Click() event, it finds no control in cE tableCell.
It seems that the controls added to cE only have their live time in
Page_Load(). Would you please tell me how persist the live time
of those dynamic web user control from Page_Load() into btnUpdate_Click() ?
Thank you
hb