双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

asp.net Repeater 第二次绑定出现 “未将对象引用设置到对象的实例。”

u010393040 u010393040 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

public void BindrepStudentList(int num)
{
DataTable dt = StudentBll.GetInfoByNum(num);
this.repStudentList.DataSource = dt;
this.repStudentList.DataBind();
dt = null;
}
这里的参数num是下面sql 语句用到的start
public DataTable GetInfoByNum(int start)
{
if (start > 1)
return SqlDbHelper.ExecuteDataTable(@"select top 5 stuID,stuName,stuSex,IdentificationNumber,className,stuYear from tb_Student s inner join tb_Class c
on s.classID = c.classID where stuID>all(select top " + (start - 1) + " stuID from tb_Student order by stuID asc) ");
else
{
return SqlDbHelper.ExecuteDataTable(@"select top 5 stuID,stuName,stuSex,IdentificationNumber,className,stuYear from tb_Student s inner join tb_Class c
on s.classID = c.classID ");
}
}
第一次加载数据没问题,关键是第二次翻页的时候,我是使用jq用ajax跳转到一般处理程序加载数据的
private void DoLoadData()
{
string strStartNum = context.Request.Params["startNum"];
if (!PageHelper.IsNum(strStartNum))
{
AjaxMsgHelper.AjaxMsg("error", "Ajax传值,传向StudentManager.ashx页面的参数异常.");
}
else
{
Web.Manager.View.StudentManager StudentManager = new View.StudentManager();
StudentManager.BindrepStudentList(int.Parse(strStartNum));
}
}
就这样又调用最上面的方法 ,然后就出错了
<html>
<head>
<title>未将对象引用设置到对象的实例。</title>
<meta name="viewport" content="width=device-width" />
<style>
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
@media screen and (max-width: 639px) {
pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
}
@media screen and (max-width: 479px) {
pre { width: 280px; }
}
</style>
</head>

<body bgcolor="white">

<span><H1>“/”应用程序中的服务器错误。<hr width=100% size=1 color=silver></H1>

<h2> <i>未将对象引用设置到对象的实例。</i> </h2></span>

<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

<b> 说明: </b>执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

<br><br>

<b> 异常详细信息: </b>System.NullReferenceException: 未将对象引用设置到对象的实例。<br><br>

<b>源错误:</b> <br><br>

<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code><pre>

行 21: {
行 22: DataTable dt = StudentBll.GetInfoByNum(num);
<font color=red>行 23: this.repStudentList.DataSource = dt;
</font>行 24: this.repStudentList.DataBind();
行 25: dt = null;</pre></code>

</td>
</tr>
</table>

<br>

<b> 源文件: </b> e:\论文项目\SkillExamination\SkillExamination.Web\Manager\View\StudentManager.aspx.cs<b>    行: </b> 23
<br><br>

<b>堆栈跟踪:</b> <br><br>

<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code><pre>

[NullReferenceException: 未将对象引用设置到对象的实例。]
SkillExamination.Web.Manager.View.StudentManager.BindrepStudentList(Int32 num) in e:\论文项目\SkillExamination\SkillExamination.Web\Manager\View\StudentManager.aspx.cs:23
SkillExamination.Web.Manager.Action.StudentManager.DoLoadData() in e:\论文项目\SkillExamination\SkillExamination.Web\Manager\Action\StudentManager.ashx.cs:67
SkillExamination.Web.Manager.Action.StudentManager.SonLoad() in e:\论文项目\SkillExamination\SkillExamination.Web\Manager\Action\StudentManager.ashx.cs:21
SkillExamination.Web.Manager.Action.AdminBaseHandler.ProcessRequest(HttpContext context) in e:\论文项目\SkillExamination\SkillExamination.Web\Manager\Action\AdminBaseHandler.ashx.cs:23
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
</pre></code>

</td>
</tr>
</table>

<br>

<hr width=100% size=1 color=silver>

<b>版本信息:</b> Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.34212

</font>

</body>
</html>
...全文

相关推荐

asp.net SqlDataReader绑定Repeater

一直以为不可以,原来是可以的,肤浅啊! 代码如下:&lt;&#37;@ Page Language=”C#” %> &lt;&#37;@ Import Namespace=”System.Data.SqlClient” %> &lt;&#37;@ Import Namespace=”System.Data” %> [removed] protected void Page_Load(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(“server=.;database=dnt;user id=ahuinan;pwd=1

weixin_38733733

【ASP.NET】第九课——使用DataList控件和Repeater控件绑定数据

GridView 和 DetailsView 控件一般合作使用,实 现“列表/详细”功能。DetailsView 控件和 GridView 控件有很多相似之处,但是 DetailsView 控件有添加数据的功能,而 GridView 没有。

逍遥小丸子

ASP.NET中repeater控件用法实例

主要介绍了ASP.NET中repeater控件用法,实例分析了repeater控件数据绑定、删除等相关技巧,具有一定实用价值,需要的朋友可以参考下

weixin_38537777

asp.net Repeater控件 应用实例 简单的留言板

asp.net Repeater控件 应用实例 简单的留言板

zhangteng335

asp.net Repeater 数据绑定的具体实现(图文详解)

以下为设计步骤: 1、在C# 中连接数据库。如下图:2、在项目中添加新建项,建立一个数据集,并把Categories从服务器资源列表中拖到这个数据集模板中并点击菜单“生成-生成解决方案”,如下图: 3、在aspx的webform上放一个ObjectDataSource控件,设定它的TypeName为刚刚建立的数据集类型,用它的向导建立即可。4、在aspx的webform上放一个Repeater控件,用它的向导设定它的DataSourceID为上面的ObjectDataSource5、在网页中设定它的源码,即加上<itemTemplate><AlternatingItemTemplate>等

weixin_38656226
评论 14
收藏 已收藏
分享
返回顶部
u010393040
.NET社区 62,274 成员 668,968 内容