473,386 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Access dynamically created TextBoxes

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 2184
Plater
7,872 Expert 4TB
Record the information when a postback occurs?
Dec 29 '08 #2
Frinavale
9,735 Expert Mod 8TB
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
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...
3
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...
1
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...
0
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...
6
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...
3
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...
4
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...
1
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.