比如有二个表:
表a1:       表b1:
aid aname    bid  bname   aname
1  苹果        1   小白
2  香蕉    2   小黑
3  桔子        3   小猪
现有a.ascx用datalist显示a1水果表,
<asp:RadioButton ID="RadioButton1" runat="server"  Text='<%# Eval("aid") %>' />
<asp:Label ID="Label1" runat="server" Text='<%# Eval("aname") %>'></asp:Label>
其它代码略....b.aspx页面调用a.ascx,
现在有幼儿园老师给小朋友分水果,请问我如何作可以在b.aspx里获取a.ascx里datalist1里的label1的值,
好让我分配给小朋友。

解决方案 »

  1.   

    Sorry,看错了
    lz的意思是:b页面上方一个a.ascx吧,哈哈 
    a.ascx
    public string Name = "Hello";
    b.aspx
    a control = new a();
     Response.Write(control.Name);
      

  2.   

    晕,又搞错了 WebUserControl control = new WebUserControl();
     Response.Write(control.Name);
      

  3.   

    在b页面中
    Label lblTemp = (Label)ucA.FindControl("DataListName").FindControl("labelName");
      

  4.   

    sunshine_anycall :
    Label lblTemp = (Label)ucA.FindControl("DataListName").FindControl("labelName");
    这个方法提示 System.NullReferenceException: 未将对象引用设置到对象的实例 
    Teng_s2000 :
    WebUserControl control = new WebUserControl();
    我的.net里只有WebControl,没有 WebUserControl。是要using引用什么呢?
      

  5.   

    感谢sunshine_anycall ,Teng_s2000 
    因为用的是DATALIST,所以要分开完成
             DataList dl = (DataList)goods1.FindControl("datalist1");
            foreach (DataListItem item in dl.Items)
            {
                RadioButton rb = (RadioButton)item.FindControl("RadioButton1");
                if (rb.Checked == true)
                {
                    Label lb = (Label)item.FindControl("Label2");//ascx里的Label
                    Label1.Text = lb.Text;//aspx里的label
                }
            }