未将对象引用设置到对象的实例.很奇怪的问题.
在DATALIST中找寻CHECKBOX和TEXTBOX
总是报这错.但在ItemCommand这个命令里面又可以找到CHECKBOX和TEXTBOX这两个子控件
报错的地方就是在
private void Datalist1_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
TextBox tb = (TextBox)e.Item.FindControl( "txtVipExpireTime ");
}
}
和当按钮删除时找不到控件
private void Button1_Click(object sender, System.EventArgs e)
{
//
BLL.RegUsers BReg = new BLL.RegUsers();
BLL.Business BBusiness = new BLL.Business();
BLL.Products BProducts = new BLL.Products();
BLL.NewsInfo BNewsInfo = new BLL.NewsInfo();
BLL.CreditInfo BCreditInfo = new BLL.CreditInfo();
BLL.ReferInfo BReferInfo = new BLL.ReferInfo();
int val = 0;
foreach(DataListItem myitem in this.Datalist1.Items)
{
CheckBox chk = (CheckBox)myitem.FindControl( "myCheck ");
if(chk.Checked)
{
String username = this.Datalist1.DataKeys[myitem.ItemIndex].ToString();
val = BReg.DeleteUser(username); //删除用户
BBusiness.DeleteUserBusiness(username);//删除用户所有商机
BProducts.DeleteUserProduct(username);//删除用户所有产品
BNewsInfo.DeleteUserNews(username);//删除用户所有新闻
BCreditInfo.DeleteUserCreditInfo(username);//删除用户公司管理证书
BReferInfo.DeleteUserRefer(username,username);//删除用户发出所有询盘和接收询盘
BCreditInfo.DeleteUserCreditInfo(username);
}
}
}
刚刚都好的.什么错都没有.一打开VS发现这个页面的有几个事件丢失了.然后又重新添加.添加后就这样了.找不到原因.有点郁闷.帮忙看看.谢谢.
------解决方案--------------------vs2003有这个毛病