473,569 Members | 2,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access dynamically created TextBoxes

1 New Member
I want to know the code how to save data from dynamically created textboxes.
The code I have written is this in whch I have dynamically created label and textboxes in a html table.The data in the label is from a table

The code I have written so far is

Expand|Select|Wrap|Line Numbers
  1. protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         SqlCommand cmd = new SqlCommand("select * from Categories", cnn);
  4.         SqlDataReader dr;
  5.         cnn.Open();
  6.         dr = cmd.ExecuteReader();
  7.         int i = 1;
  8.         while (dr.Read())
  9.         {
  10.             row = new TableRow();
  11.  
  12.             cell = new TableCell();
  13.             label1 = new Label();
  14.             label1.Text = dr["CategoryName"].ToString();
  15.             cell.Text = label1.Text;
  16.             row.Cells.Add(cell);
  17.  
  18.             cell = new TableCell();
  19.             text = new TextBox();
  20.             text.ID = "text" + i;
  21.             cell.Controls.Add(text);
  22.             row.Cells.Add(cell);
  23.  
  24.             Table1.Rows.Add(row);
  25.             i++;
  26.  
  27.         }
  28.         cnn.Close();
  29.         dr.Close();
  30.     }
  31.  
can anyone tell how do i save data whch the user enter at run time
Dec 27 '08 #1
2 2192
Plater
7,872 Recognized Expert Expert
Record the information when a postback occurs?
Dec 29 '08 #2
Frinavale
9,735 Recognized Expert Moderator Expert
Please check out this article on how to use dynamic controls in ASP.NET.

You are creating your TextBoxes in the Page Load event. The Page Load event happens after the ViewState for all of the controls on the page has been loaded...this means that the TextBoxes will not be loaded with the data that the user enters.

Take a quick look at the article and see if it helps you solve your problem.

-Frinny
Dec 29 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
565
by: Bhavin | last post by:
Anybody quickly replies it, would be a great help! I try to create dynamic array of textboxes control in ASP.NET(C#). I got the following error while I tried to assign value to ID property of dynamically created textbox. (look at my code please ) Error: “ Object reference is not set to an instance of Object” totalRows – int...
3
5279
by: Forconi Boris via .NET 247 | last post by:
Hi, I'm working on a project in witch I have to list data(products that can be selected with a certain quantity) from anXML document, with key words entered by the user. A Table isdynamically created with text, and in each row, there 's atextBox (with an incremental ID number) in witch the user canenter a number of products. When the user clicks...
1
2115
by: RC | last post by:
Hi, I 've created a form with serveral Dynamically Created TextBoxes and a static button. After press the button, those values of TextBoxes should be posted back to server. How to get the value back from those boxes? Any Sample Code Provided? Thanks RC
0
1995
by: Silver Oak | last post by:
I have a DataGrid in which one of the columns is TemplateColumn that was created dynamically using iTemplate. I would like to have multi-row editing capability on the DataGrid. I'm trying to follow the example in MSDN...
6
1484
by: Bjorn Sagbakken | last post by:
Hello In VS2005: I am adding buttons and textboxes dynamically into a table, that also dynamically expands. So far, so good, actually very nice. But I am having trouble starting the desired subroutine on postback. To me it seems like the button click event looks for a client script instead of going to the aspx codepage and execute the sub...
3
2415
by: raghulvarma | last post by:
I have created only one object for the textbox and that particular textbox is being repeated as many times I want.But if I want to add the values in the database from each and every textbox which have been dynamically created how should I do that? I have uesd dropdown box to get the number of textboxes to be displayed and used panel to display...
4
4746
by: =?Utf-8?B?RHlsYW5TbWl0aA==?= | last post by:
I have a WebForm where I'm dynamically creating some controls and I'm having difficulty understanding how the state is being persisted and how to work with it. I've created a simplified example to demonstrate my issues. Lets say I have a WebForm with a DropDownList where the user selects a number from 1 to 10 (the DropDownList is not...
1
6304
by: JFKJr | last post by:
Hello everyone, the following Access VBA code opens an excel file and creates textboxes in a given range of cells dynamically. The code attaches "MouseUP" and "Exit" events to the textboxes (using the following "DateTextBox" class module). Whenever a user enters in to the textbox, the code displays "Please enter date in mm/dd/yyyy format (for...
1
2307
by: bharathi228 | last post by:
hi, iam doing a windows application.i have a requirement like to create labels and textboxes dynamically at runtime.iam giving input as number of labels,and textboxes then it will created dynamically.but here i put this controls in a panel.here my problem is all controls are placed in the same position. but my requirement is all textboxes are...
0
7697
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.