Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何在按钮上获取动态创建的文本框的值单击_Asp.net_C# 4.0_Dynamic - Fatal编程技术网

Asp.net 如何在按钮上获取动态创建的文本框的值单击

Asp.net 如何在按钮上获取动态创建的文本框的值单击,asp.net,c#-4.0,dynamic,Asp.net,C# 4.0,Dynamic,我创建了两个动态表和文本框,如下所示: protected void drpNetworkList_SelectedIndexChanged(object sender, EventArgs e) { string socialNetworkName = drpNetworkList.SelectedItem.Text; DataSet networkdata = VoCServiceObj.GetSocailNetworkNameDetails(partnerid,so

我创建了两个动态表和文本框,如下所示:

protected void drpNetworkList_SelectedIndexChanged(object sender, EventArgs e)
    {
     string socialNetworkName = drpNetworkList.SelectedItem.Text;

DataSet networkdata =   VoCServiceObj.GetSocailNetworkNameDetails(partnerid,socialNetworkName);           

        int cdount = networkdata.Tables[0].Rows.Count;

            pnlViewData.Controls.Clear();
            Check.Checked = true;               
            pnlViewData.Visible = true;
            table = new Table();
            table.ID = "tbl_dy";

            //Brandurl
            row = new TableRow();
            cell = new TableCell();

            Label lbl = new Label();
            lbl.ID = "lbl_1";
            lbl.Text = "BrandURL";
            cell.Controls.Add(lbl);
            row.Cells.Add(cell);

            cell = new TableCell();
            TextBox txt = new TextBox();
            txt.ID = "textBox";
            txt.Text = networkdata.Tables[0].Rows[0]["BrandDestinationURL"].ToString();
            cell.Controls.Add(txt);
            row.Cells.Add(cell);
            table.Rows.Add(row);

            for (int i = 1; i <= cdount; i++)
            {
                int count = i - 1;

                //ProdutId
                row = new TableRow();
                cell = new TableCell();

                Label lbl2 = new Label();
                lbl2.ID = "lbl_1'" + i + "'";
                lbl2.Text = "ProductID" + i + "'";
                cell.Controls.Add(lbl2);
                row.Cells.Add(cell);

                cell = new TableCell();
                TextBox txt2 = new TextBox();
                txt2.ID = "textBox1" + i + "'";
                txt2.Text = networkdata.Tables[0].Rows[count]["ProductID"].ToString();
                cell.Controls.Add(txt2);
                row.Cells.Add(cell);

                table.Rows.Add(row);

                //ProdutURL
                row = new TableRow();
                cell = new TableCell();

                Label lbl3 = new Label();
                lbl3.ID = "lbl_2'" + i + "'";
                lbl3.Text = "ProductURL" + i + "'";
                cell.Controls.Add(lbl3);
                row.Cells.Add(cell);

                cell = new TableCell();
                TextBox txt3 = new TextBox();
                txt3.ID = "textBox2" + i + "'";
                txt3.Text = networkdata.Tables[0].Rows[count]["ProductDestinationURL"].ToString();
                cell.Controls.Add(txt3);
                row.Cells.Add(cell);

                table.Rows.Add(row);

            }
            pnlViewData.Controls.Add(table);

    }
   protected void imgSave_Click(object sender, ImageClickEventArgs e)
    {
                    TextBox tb1 = (TextBox)Page.FindControl("textBox11");
        String str = string.Empty;
        str = tb1.Text;
    }
protectedvoid drpNetworkList\u SelectedIndexChanged(对象发送方,事件参数e)
{
string socialNetworkName=drpNetworkList.SelectedItem.Text;
DataSet networkdata=VoCServiceObj.GetSocailNetworkNameDetails(partnerid,socialNetworkName);
int cdount=networkdata.Tables[0].Rows.Count;
pnlViewData.Controls.Clear();
Check.Checked=true;
pnlViewData.Visible=true;
table=新表();
table.ID=“待定”;
//Brandurl
行=新表行();
单元格=新表单元格();
标签lbl=新标签();
lbl.ID=“lbl_1”;
lbl.Text=“BrandURL”;
cell.Controls.Add(lbl);
行.单元格.添加(单元格);
单元格=新表单元格();
TextBox txt=新的TextBox();
txt.ID=“textBox”;
txt.Text=networkdata.Tables[0]。行[0][“BrandDestinationURL”]。ToString();
cell.Controls.Add(txt);
行.单元格.添加(单元格);
table.Rows.Add(行);

对于(int i=1;i每次创建页面时都会创建所有页面控件

在事件上动态创建的控件必须在下一次
Init
时重新创建

只有在
ProcessPostData
之前创建的控件才能接收用户输入的数据

您可以使用
ViewState
记住下次必须重新创建这些控件