如题!
我想做一个用户控件,里面有GridView,然后将这个用户控件放到页面中,然后再动态指定这个用户控件里GridView的数据源及其他属性,并读取、修改数据?谢谢!!

解决方案 »

  1.   

    public GridView GridView1
    {
      get{
      return this.GridView1;
    }
    }
      

  2.   

    cpp2017(慕白兄),能不能说详细点,我是刚入门的,谢谢!!
      

  3.   

    你在用户控件中这样声明后,就可直接访问这个GridView了
      

  4.   

    声明了,但我访问时,只有gridview的databind(),找不到datasource这个属性啊。
      

  5.   

    你可能是文件名取重了,文件名不要叫GridView,或者直接改那个Class 的名,不要叫GridView
      

  6.   

    还有很多属性都没有,比如说headertext等等
      

  7.   

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;public partial class GridView : System.Web.UI.UserControl
    {
        private string title;
        
        public string Title
        {
            get { return title; }
            set { title = value;}    }    public GridView uGridView
        {
            get
            {
                return uGridView;
            }
        }    protected void Page_Load(object sender, EventArgs e)
        {
            LabTitle.Text = title;
            
        }    
    }这是代码,
    然后我将此用户控件拖入一个页面中,在页面这样访问
        protected void Page_Load(object sender, EventArgs e)
        {
            GridViewForm1.Title = "省份设置";
            
        }
    这里Title运行时可以正确显示,
    但想我加上GridViewForm1.DataSource,
    GridViewForm1.HeaderText 这些属性设置时,智能感应却找不到这些属性。
      

  8.   

    class GridView 
    这个类名最好改一下.
    2.GridViewForm1.uGridView 应该可以访问的