动态加载了Player.ascx用户控件 并取出了值a.
请问怎么把a值传给Player.ascx控件呢
    public void GridViewGuttonField(Object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "select")
        {
            string controlName = "Player.ascx";
            UserControl control = (UserControl)Page.LoadControl("ascx/" + controlName);
            PlaceHolder1.Controls.Add(control);
            int index = Convert.ToInt32(e.CommandArgument);
            string a= GridView1.Rows[index].Cells[0].Text;
        }
    }
-----------------------------------------------
player.ascx
网上的说加在plyer.ascx加个
        private string _scr;
        public string scr
        {
            get
            {
                return _scr;
            }
            set
            {
                _scr = value;
            }
        }
但不知道怎么用
麻烦详细点,谢谢了,

解决方案 »

  1.   

    public void GridViewGuttonField(Object sender, GridViewCommandEventArgs e) 
        { 
            if (e.CommandName == "select") 
            { 
                string controlName = "Player.ascx"; 
                UserControl control = (UserControl)Page.LoadControl("ascx/" + controlName); 
                control.scr = 值;//把值传过去
                PlaceHolder1.Controls.Add(control); 
                int index = Convert.ToInt32(e.CommandArgument); 
                string a= GridView1.Rows[index].Cells[0].Text; 
            } 
        } 
      

  2.   

    出错:System.Web.UI.UseControl并不包含"src"的定义,我之前也是这样试..是不是还缺少什么的?比如:命名空间等.
                string controlName = "Player.ascx";
                UserControl control = (UserControl)Page.LoadControl("ascx/" + controlName);
                int index = Convert.ToInt32(e.CommandArgument);
                string a=GridView1.Rows[index].Cells[0].Text;
                control.src=a;
                PlaceHolder1.Controls.Add(control);
      

  3.   

    public void GridViewGuttonField(Object sender, GridViewCommandEventArgs e) 
        { 
            if (e.CommandName == "select") 
            { 
                string controlName = "Player.ascx"; 
                UserControl control = (UserControl)Page.LoadControl("ascx/" + controlName); 
                PlaceHolder1.Controls.Add(control); 
                int index = Convert.ToInt32(e.CommandArgument); 
                string a = 值;//把值传过去
                  control.src=a
            } 
        }
      

  4.   

    class player
    { private string _scr; 
            public string scr 
            { 
                get 
                { 
                    return _scr; 
                } 
                set 
                { 
                    _scr = value; 
                } 
            } 
    .............}
      

  5.   

    没有满意答案.结贴.发现csdn...高手不多...菜鸟多多.
      

  6.   

    scr被定义为了属性,你只能使用get ,set两种方法对_scr操作,也就是这能设置和读取_scr值
      

  7.   

    在用户控件Player.ascx的cs文件中加入你上面那一段
    private string _scr; 
            public string scr 
            { 
                get 
                { 
                    return _scr; 
                } 
                set 
                { 
                    _scr = value; 
                } 
            }