C# ASP.NET:如何从数据库加载用户控件并向其发送参数?

C# ASP.NET:如何从数据库加载用户控件并向其发送参数?,c#,asp.net,C#,Asp.net,我有一个表,其中包含用户控件名和页面中的位置。在页面中,在每个位置加载我的所有面板,加载一个用户控件。 我的立场是这样的: 这是我的代码,用于从数据库中加载usercontrol名称,并将它们设置为其位置,如下图所示,但我想向每个用户控件发送参数,但如何发送 private void loadUCposition() { string sql = "select ucname,positionid,StringParameter from Position p inner join m

我有一个表,其中包含用户控件名和页面中的位置。在页面中,在每个位置加载我的所有面板,加载一个用户控件。
我的立场是这样的:

这是我的代码,用于从数据库中加载usercontrol名称,并将它们设置为其位置,如下图所示,但我想向每个用户控件发送参数,但如何发送

private void loadUCposition()
{
    string sql = "select ucname,positionid,StringParameter from Position p inner join modulename mn on p.modulid=mn.ucid" +
        "";
    DataTable dt = ADO.setDg_DataTable(sql);

    foreach (DataRow row in dt.Rows)
    {
        string pos = row[1].ToString();
        string ucs = row[0].ToString();
        Panel p = this.Master.FindControl("ContentPlaceHolder1").FindControl("p"+pos) as Panel;

        UserControl uc = new UserControl();
        if (ucs.IndexOf(".ascx") > 0)
        {

            uc = this.LoadControl(ucs) as UserControl;
        }
        else
        {
            uc = this.LoadControl(ucs + ".ascx") as UserControl;
        }
        uc = this.LoadControl(ucs) as UserControl;
        p.Controls.Add(uc);
    }
}

当您指的是为用户控件设置参数时,我想您指的是在标记中设置值

<myUserControl parameter1="1" parameter2="2" />
uc = this.LoadControl(ucs) as UserControl;
p.Controls.Add(uc);
// Modify new instance's public member variables
uc.positionX = 123123;
uc.parameter1 = 1;
uc.parameter2 = 2;