Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 14th, 2004, 09:08 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Hyderabad, , India.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamically displaying textboxes and label

Hi
How to display textboxes and labels inside the table dynamically in C#.
I have to pass the textbox id and text in the stored procedure for storing into the database.
I written like this :

TextBox TempTextBox = (TextBox)PlaceHolder1.FindControl("textBox1");

With the help of this initialisation, I am unable to pass the text box value and id and I dont know how to display inside the table.
I hope this time I ll get my answer.


Lily

Reply With Quote
  #2 (permalink)  
Old December 15th, 2004, 06:59 PM
Authorized User
 
Join Date: Jan 2004
Location: santa monica, ca, .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to rathbird
Default

I'm not too clear about what you're asking. Say you have a table with the ID myTable, a row with the ID myTableRow, and a cell myTableCell, and on some event you want to create a textbox with a value and an id, here's how you would do it:

private void Page_Load(object sender, System.EventArgs e)
{
  //I assume you're getting your values correctly from SQL
  // also assuming that you've passed your values into variables
  // which i'll name myTextBoxID and myTextBoxValue

  //Create a textbox control

  TextBox _tb = new TextBox();

  //Set the id of the textbox

  _tb.ID = myTextBoxID;

  //Set the value of the textbox

  _tb.Text = myTextBoxValue;

  //Add the control to your table cell

  myTableCellID.Controls.Add(_tb);

}

Now I put the code to build the textbox in the page_load event handler, but you would probably make it a separate function call. Also, remember that dynamic content must be built every time you post the page; for some reason it disappears on postback if you don't call it again.

Also, it is very easy to create Tables, rows, and cells dynamically, and if you need the code to do this as well, please send me an email. I hope this helps.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression Validator displaying a label thomaswharmanjr26 C# 0 January 25th, 2008 03:38 PM
Dynamically populate a label MaxGay2 VB.NET 2002/2003 Basics 27 November 15th, 2006 04:17 PM
Dynamically generated textboxes and their values Frode ASP.NET 2.0 Basics 1 April 17th, 2006 03:46 PM
Dynamically Generating Textboxes Maxood PHP How-To 6 March 9th, 2006 09:14 AM
Using the IDs of dynamically created textboxes mahulda ASP.NET 1.0 and 1.1 Basics 3 February 17th, 2004 05:05 AM



All times are GMT -4. The time now is 05:39 AM.


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