Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 22nd, 2006, 06:24 AM
Registered User
 
Join Date: May 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Saving Data to DB in dynamically created control

Hi Everyone,
My requirement is to create a couple of text boxes dynamically and save
data in those text boxes after entering data into them. The way in whic
i tried was:
TextBox txt = new TextBox();
for(i=0;i<5;i++)
{
Page.Controls.Add(txt);
}
The erroe i am gettint is The text box has to be place on a for with
runat = server
I will be glad to read from you
thanks and regards
Ashok


ashok
 
Old June 22nd, 2006, 10:50 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Ashok,
Do something like this on your aspx page.

<form runat="server">
<asp:panel id="pnlControls" runat=server visible="true"/>
</form>

In your codebehind instead of Page.Controls.Add(txt) do this:

pnlControls.Controls.Add(txt);

"The one language all programmers understand is profanity."
 
Old June 23rd, 2006, 01:18 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Try:
Me.FindControl("Form1").Controls.Add(txt);






Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help me about dynamically created controls vingo_mail ASP.NET 2.0 Basics 1 March 24th, 2008 12:54 PM
Saving a Public Property created in App_Code striker9 ASP.NET 2.0 Basics 1 June 8th, 2006 02:18 PM
Dynamically created code Puck312 Pro VB 6 3 September 7th, 2005 01:21 PM
Dynamically created controls katsarosj ASP.NET 1.0 and 1.1 Basics 4 February 4th, 2004 09:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.