Help!! how to get the value of dynamic web user control?

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
 
S

Steven Cheng[MSFT]

Hi Hb,

Have you had a chance to check out the suggestions in my last reply or have
you got any further ideas on this issue? If you have anything unclear or if
there're anything else we can help, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top