前台 .aspx
    <form id="form1" runat="server">
    
<asp:Label runat="server" ID="panel" Visible="false"></asp:Label>
        
<table border="0" cellpadding="0" cellspacing="2" width="100%">
            
<tr>
                
<td>
                    
<div style="text-align: left;">
                        
<asp:Panel ID="pan" runat="server"></asp:Panel>
                    
</div>
                    
<div style="text-align: center;padding-top:5px;">
                        
<input type="button" runat="server" id="save" style="width:80px;border:#333333 1px solid" value="确定" onserverclick="save_ServerClick" />
                        
<input type="button" id="reset" value="取消" style="width:80px;border:#333333 1px solid" onclick="javascript:window.opener=null;window.close();" />
                    
</div>
                
</td>
            
</tr>
        
</table>
    
</form>

.cs 后台代码
  /// <summary>
    
/// 创建 num 个TextBox
    
/// </summary>
    
/// <param name="num">个数</param>

    protected void CreateTextBox(int num,string[] str)
    
{
        
for (int i = 0; i < num; i++)
        
{
            TextBox tbox 
= new TextBox();
            Label lbl 
= new Label();
            Label lb 
= new Label();
            
if (i == 0)
            
{
                lbl.Text 
= "定价:";
            }

            
else
            
{
                lbl.Text 
= "<br />定价:";
            }

            lb.Text 
= "编号:(" + str[i] + ")";
            tbox.Style.Add(
"width""100px");
            tbox.Style.Add(
"border""#333333 solid 1px");
            pan.Controls.Add(lbl);
            pan.Controls.Add(tbox);
            pan.Controls.Add(lb);
        }

    }

    
protected void save_ServerClick(object sender, EventArgs e)
    
{
        
//遍历页面中Span容器中的所有控件
        foreach (Control mycontrol in Page.FindControl("pan").Controls)
        
{
            
//如果控件是TextBox或者Label
            if (mycontrol.GetType() == typeof(TextBox) || mycontrol.GetType() == typeof(Label))
            
{
                
string bookid = "";
                
string bookvalue = "";
                
if (mycontrol.GetType() == typeof(TextBox))
                
{
                    bookvalue 
= ((TextBox)mycontrol).Text.Trim();   //赋值
                }

                
else
                
{
                    
if (((Label)mycontrol).Text != "定价:")
                    
{
                        bookid 
= ((Label)mycontrol).Text.Trim();    //赋值
                    }

                }

                
if (bookid != "" && bookvalue != "")    //如果 bookid 和 bookvalue 都不为空 执行具体数据操作
                {
                    ;
                }

            }

        }

    }