//引用传递改变值。把Hashtable 放入Session中 用来判断是不是第一次执行 不是就不执行
Session["settingvalue"] = SetViewState(RolesName, cblist, ref count);

public Hashtable SetViewState(string RolesName, CheckBoxList cblist, ref int count)
        {
            //判断是不是第一次访问
            if (count == 0)
            {
                ht = new Hashtable();
            }
            ht.Add(RolesName, cblist);

            count = 1;

            return ht;
        }
//动态添加控件  获取值 用到了Placeholder控件。
<div>
<asp:LinkButton ID="AddRow" runat="server" Style="position: relative">实名</asp:LinkButton><asp:TextBox
ID="RowCount" runat="server" Style="position: relative" Width="30px">1</asp:TextBox>&nbsp;
<asp:Button ID="btn_get" runat="server" OnClick="btn_get_Click" Style="position: relative"
Text="取值" /><br />
<asp:Panel ID="Panel1" runat="server" Height="50px" Style="position: relative; left: 0px; top: 0px;" Width="1045px">
</asp:Panel>
</div>


        if (!IsPostBack)
        {
            Session["shiming"] = RowCount.Text;
            add();
            Response.Write("回传页面(ispostback)<br />");

        }
        else
        {
            Session["shiming"] = 1;
            add();
            Response.Write("第一次加页面(!ispostback)");
        }


protected void add()
    {
        if (Session["shiming"] != null)
        {
            for (int i = 1; i <= Convert.ToInt32(Session["shiming"]); i++)
            {
                Label lbl = new Label();
                TextBox txt2 = new TextBox();

                lbl.ID = "lbl_shiming_" + i;
                lbl.Text = "实名" + i + ":";
                txt2.ID = "txt2_shiming_" + i;

                Panel1.Controls.Add(lbl);
                Panel1.Controls.Add(txt2);

                Panel1.Controls.Add(new LiteralControl("<br   />"));
            }
        }
     
    }


protected void btn_get_Click(object sender, EventArgs e)
    {
        for (int i = 1; i <= Convert.ToInt32(Session["shiming"]); i++)
        {
            Response.Write(((TextBox)Panel1.FindControl("txt2_shiming_" + i)).Text + "<br/>");
        }
    }