| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 791 人关注过本帖
标题:[求助]请各位高手帮忙
只看楼主 加入收藏
tong5221
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2005-5-8
收藏
 问题点数:0 回复次数:5 
[求助]请各位高手帮忙
public void MyDataGrid_ItemDataBound(object sender,System.Web.UI.WebControls.DataGridItemEventArgs e) { foreach (DataGridItem i in MyDataGrid.Controls[0].Controls) { string sql0="select * from xcompany where c_id="+this.zid.Text; DataSet ds0=new DataSet(); ds0=conn.executeQuery(sql0); Response.Write("aa"+sql0+"<br>"); System.Web.UI.WebControls.DataGrid DataGrid1=(DataGrid)i.FindControl("DataGrid1"); DataGrid1.DataSource=ds0; DataGrid1.DataBind(); } } 这段代码为在数据绑定的时候为什么绑定不上,会出现如下错误: System.NullReferenceException: 未将对象引用设置到对象的实例。 行 94:System.Web.UI.WebControls.DataGrid DataGrid1=(DataGrid)i.FindControl("DataGrid1"); 行 95:DataGrid1.DataSource=ds0; 行 96:DataGrid1.DataBind();
搜索更多相关主题的帖子: public where 
2005-05-08 08:20
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
加注释来看看

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-05-08 08:49
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
见意你。插入用insert,更新用update,删除用delete.
不要用sql0. 看不明白

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-05-08 08:55
tong5221
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2005-5-8
收藏
得分:0 
public void MyDataGrid_ItemDataBound(object sender,System.Web.UI.WebControls.DataGridItemEventArgs e) { foreach (DataGridItem i in MyDataGrid.Controls[0].Controls) { string sql0="select * from xcompany where c_id="+this.zid.Text; //取出在XCOMPANY表中c_id和zcompany表中ID相同的内容 DataSet ds0=new DataSet(); ds0=conn.executeQuery(sql0); Response.Write("aa"+sql0+"<br>"); System.Web.UI.WebControls.DataGrid DataGrid1=(DataGrid)i.FindControl("DataGrid1"); DataGrid1.DataSource=ds0; DataGrid1.DataBind(); } } 这段代码为在数据绑定的时候为什么绑定不上,会出现如下错误: System.NullReferenceException: 未将对象引用设置到对象的实例。 行 94:System.Web.UI.WebControls.DataGrid DataGrid1=(DataGrid)i.FindControl("DataGrid1"); 行 95:DataGrid1.DataSource=ds0; 行 96:DataGrid1.DataBind();

2005-05-08 09:09
tong5221
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2005-5-8
收藏
得分:0 
这个是DATAGRID的嵌套,上面这段代码就是第二个DATAGRID的数据绑定,可是不知为什么就是绑定不上,总是“未将对象引用设置到对象的实例”这个错误。

2005-05-08 09:11
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-05-08 09:32
快速回复:[求助]请各位高手帮忙
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018412 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved