?
Solved

create server control dynamically in asp.net

Posted on 2013-12-13
1
Medium Priority
?
343 Views
Last Modified: 2013-12-16
I have multiple forms and each form has its own page. I want to combine them to a single page and have server control gets create dynamically. Should I store each control id, name in sql? When page loads, how to it bind each control to value from db?  How should I go about doing something like this?  It could be done!
0
Comment
Question by:VBdotnet2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 2000 total points
ID: 39718450
Controls are nothing but class in .NET.

Say for example, if you want to adde a text box dynamically in to a server control C, you could follow below code.

TextBox txtBox = new TextBox();

txtBox.ID ="txtOption" + Rand().ToString();
txtBox.Width= Unit.Pixel(45);
txtBox.MaxLength = 2;

c.Controls.Add(txtBox);

//Then finally the server control could be added to page.

Page.Controls.Add(c);

Please do refer

 http://www.codeproject.com/Articles/14450/Dynamic-creation-of-ASP-NET-server-controls-on-fly

http://couldbedone.blogspot.in/2007/06/dynamically-created-controls-in-aspnet.html

http://www.dreamincode.net/forums/topic/328007-add-aspnet-controls-dynamically/

for more information.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question