如何保存动态创建的文本框的值 [英] how to save the values of dynamically created textbox

查看:60
本文介绍了如何保存动态创建的文本框的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我动态创建的文本框的代码,其中包含指定的列数



here is my code for dynamically created textbox with specified no of columns

protected void btnAdd_Click(object sender, EventArgs e)
    {
        panel2.Visible = true;
        int rowCount = Convert.ToInt32(txtAdd.Text);
        Table table1 = new Table();
        table1.ID = "table3";
        for (int i = 0; i < rowCount; i++)
        {
            TableRow row = new TableRow();
            for (int j = 0; j < 7; j++)
            {
                TableCell cell = new TableCell();
                TextBox TxtBox = new TextBox();
                TxtBox.ID = "TextBoxRow_" + i + "Col_" + j;
                TxtBox.Attributes.Add("runat", "Server");
                // cell.ID = "cell" + j.ToString() ;
                cell.Controls.Add(TxtBox);
                row.Cells.Add(cell);
            }
            table1.Rows.Add(row);
        }
        panel1.Controls.Add(table1);   
     }



我的问题是如何添加此文本框的值。

我收到错误对象引用未设置为对象的实例。

推荐答案

这篇关于如何保存动态创建的文本框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆