自定义控件数据加载问题
public class drpDep : DropDownList,INamingContainer
{
public drpDep()
{ }
protected override void OnPreRender(EventArgs e)
{
this.BindDrpClass();
base.OnPreRender(e);
}
private void BindDrpClass()
{
.....
}
}
页面在Page_Load时执行数据查询,填充GridView1
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataSet ds = new CategoryStatics().GetCunitStatic(this.drpDep1.SelectedValue)
this.GridView1.Datasouce=ds;
this.GridView1.Databind();
}
}
但是报错,调试发现drpDep1的数据并没有加载
我试过有OnInit(),但会出现其它问题,我应该怎么办?