469,568 Members | 1,464 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,568 developers. It's quick & easy.

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

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
Nov 18 '05 #1
1 2423
tr
Build the controls in page_load only when page.IsPostback is false

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by ronniek | last post: by
2 posts views Thread by John Ninan | last post: by
2 posts views Thread by Developer_Software | last post: by
1 post views Thread by Stanley Cheung | last post: by
1 post views Thread by Tarun Mistry | last post: by
reply views Thread by Eniac | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.