Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8983931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:57:53+00:00 2026-06-15T20:57:53+00:00

I’m trying to get Text from a dynamically craeted server textbox. I’m just checking

  • 0

I’m trying to get Text from a dynamically craeted server textbox.
I’m just checking by getting the text into another textbox I placed in the aspx file, but all I get is always an empty string..
(I also tried another method that is enclosed in remark, but it doesn’t work either)

Here’s the code behind:

public partial class Product_list : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        create_table();
    }

    protected void create_table()
    {
        DBServices db1=new DBServices();
        List<Product> list1 = db1.ReadProducts();
        int id_number=1;
        int id_numer2 = 7;
        int id_number3 = 13;

        Table tbl = new Table();
        tbl.ID = "tbl1";
        this.Controls.Add(tbl);

        foreach (Product p1 in list1)
        {
            TableRow rw = new TableRow();
            rw.ID = Convert.ToString(id_numer2);

            TableCell cell1 = new TableCell();
            cell1.Text = p1.Name;

            TableCell cell2 = new TableCell();

            Image img = new Image();
            img.ImageUrl = p1.ImagePath;
            img.Height = 50;
            img.Width = 50;

            cell2.Controls.Add(img);

            TableCell cell3 = new TableCell();
            cell3.ID = Convert.ToString(id_number3);

            TextBox textbox1 = new TextBox();
            textbox1.ID = Convert.ToString(id_number);

            cell3.Controls.Add(textbox1);

            rw.Controls.Add(cell1);
            rw.Controls.Add(cell2);
            rw.Controls.Add(cell3);

            tbl.Controls.Add(rw);

            id_number++;
            id_numer2++;
            id_number3++;
        } 
    }

    void save_list()
    {
        List<Product> Items_list = new List<Product>();

        //TextBox aControl =Page.FindControl("1") as TextBox;

        /var tbl1 = this.Page.FindControl("tbl1") as Table;
        var tr = tbl1.FindControl("7") as TableRow;
        var td = tr.FindControl("13") as TableCell;
        var txt = td.FindControl("1") as TextBox;

        txt1.Value = txt.Text;

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        save_list();
    }
}

and here is the aspx code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Product_list.aspx.cs" Inherits="Product_list" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script runat=server>
        public override void VerifyRenderingInServerForm(Control control)
        {
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div id="header">
            <h1>Items List</h1>
        </div>

        <div id="prod_table" runat="server"></div>
        <div>
            <input type="text" runat="server" id="txt1" />
            <asp:Button ID="Button1" runat="server" Text="Button"
                onclick="Button1_Click" />
        </div>
    </form>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:57:54+00:00Added an answer on June 15, 2026 at 8:57 pm

    You should understand that you recreate your table on every post to the server. So, you cannot rely on data from your dynamic table, because it would be lost after each posting. My suggestion is to keep this value in permanent input control with a type “hidden”. Then on button click event just get this value and assign it to a textbox.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am currently running into a problem where an element is coming back from
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a bunch of posts stored in text files formatted in yaml/textile (from
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.