我有一个DataList
,当它不是回发时,我在页面加载中绑定它,但是当我尝试访问事件时,我仍然收到一个空引用异常,DataItem
有ItemCreated
什么建议吗?
protected void Page_Load(object sender, EventArgs e)
{
AppPath = MapPath(HttpContext.Current.Request.ApplicationPath);
MainDS.ReadXml(AppPath + FileName);
DataView MyDV = new DataView(MainDS.Tables[0]);
DataList1.DataSource = MyDV;
DataList1.DataBind();
}
protected void DataList1_ItemCreated(object sender, DataListItemEventArgs e)
{
Response.Write(e.Item.DataItem.ToString());
}