LinkButton delButton = (LinkButton)CardDataList.FindControl("lbtnDel");
delButton.Attributes.Add("onclick","return confirm('您是否确定要删除这条信息')");这样不行,报错"未将对象引用设置到对象的实例。"为什么?该怎么做
delButton.Attributes.Add("onclick","return confirm('您是否确定要删除这条信息')");这样不行,报错"未将对象引用设置到对象的实例。"为什么?该怎么做
解决方案 »
- Pro Telerik ASP.NET and Silverlight Controls
- 用动软.Net代码生成器生成的代码报错。
- select-option问题
- javascript:history.go(-1) 到返回页面,返回页面会触发什么事件?
- 关于在innerHTML中写入.net变量的问题
- 问一下有关数据库字符串的问题
- 可不可以這樣說。能用傳遞參數代替session就盡量不要用session?
- 菜鸟新手100分求救,请大家指点,谢谢
- 做一个和csdn论坛上 我感兴趣社区--配置我感兴趣得社区 一样功能的东西!谁能给个例子啊!
- 在添加是怎么添加"null"??
- 能在.htm网页中实现这两个效果吗?急!!!
- ASP.NET环境配置问题~~
此错误信息表示,你并未找到所需要的按钮对象,此时你定义的对象名为null,添加属性的时候,当然出错。
ItemDataBound事件里添加那些代码
private void DgUser_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType ==ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
LinkButton delButton = (LinkButton)CardDataList.FindControl("lbtnDel");
if (delButton != null)
{
delButton.Attributes.Add("onclick","return confirm('您是否确定要删除这条信息');");
}
}
}
LinkButton delButton = (LinkButton)e.Item.FindContro("lbtnDel");
if (delButton!=null){
delButton.Attributes.Add("onclick","return confirm('您是否确定要删除这条信息')");
}