首页上一页 1 下一页尾页 4 条记录 1/1页
asp.net典型模块大全-在线考试系统问题
发表在ASP.NET图书答疑
2011-06-05
是否精华
是
否
版块置顶:
是
否
1、在程序SingleSelectManage.aspx.cx中的代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string loginName = Session["userID"].ToString();
Users user = new Users();
user.LoadData(loginName);
labUser.Text = user.UserName;
InitDDLData(); //初始化考试科目
}
}
在浏览器查看时出现如下错误:
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
源错误:
行 17: if (!Page.IsPostBack)
行 18: {
行 19: string loginName = Session["userID"].ToString();
行 20: Users user = new Users();
行 21: user.LoadData(loginName);
堆栈跟踪:
[NullReferenceException: 未将对象引用设置到对象的实例。]
Web_SingleSelectAdd.Page_Load(Object sender, EventArgs e) in f:\wangyebacom\OnLineExamUpdate\Web\SingleSelectAdd.aspx.cs:19
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
改为:string loginName;
if(session["userID"]!=null)
loginName = Session["userID"].ToString();
后对程序的结果有多大影响?
2、源程序TestAnswer.aspx.cx调试出现问题:
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
源错误:
行 29: SqlParameter[] Params1 = new SqlParameter[2];
行 30: DataBase DB = new DataBase();
行 31: int paperID = int.Parse(Session["PaperID"].ToString());
行 32: Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4,paperID); //试卷编号
行 33: Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选");//题目类型
源文件: f:\wangyebacom\OnLineExamUpdate\Web\TestAnswer.aspx.cs 行: 31
堆栈跟踪:
[NullReferenceException: 未将对象引用设置到对象的实例。]
Web_TestAnswer.InitData() in f:\wangyebacom\OnLineExamUpdate\Web\TestAnswer.aspx.cs:31
Web_TestAnswer.Page_Load(Object sender, EventArgs e) in f:\wangyebacom\OnLineExamUpdate\Web\TestAnswer.aspx.cs:23
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
请教老师,这个该如何更改?谢谢!
附包含改源码的部分代码程序如下:
SqlParameter[] Params1 = new SqlParameter[2];
DataBase DB = new DataBase();
int paperID = int.Parse(Session["PaperID"].ToString());
Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号
Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选题"); //题目类型
DataSet ds1 = DB.GetDataSet("Proc_PaperDetail", Params1);
GridView1.DataSource = ds1;
GridView1.DataBind();
((Label)GridView1.HeaderRow.FindControl("Label27")).Text = ((Label)GridView1.Rows[0].FindControl("Label4")).Text;
另外,程序调试是说ds1传送的是空值,郁闷!请不吝赐教
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string loginName = Session["userID"].ToString();
Users user = new Users();
user.LoadData(loginName);
labUser.Text = user.UserName;
InitDDLData(); //初始化考试科目
}
}
在浏览器查看时出现如下错误:
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
源错误:
行 17: if (!Page.IsPostBack)
行 18: {
行 19: string loginName = Session["userID"].ToString();
行 20: Users user = new Users();
行 21: user.LoadData(loginName);
堆栈跟踪:
[NullReferenceException: 未将对象引用设置到对象的实例。]
Web_SingleSelectAdd.Page_Load(Object sender, EventArgs e) in f:\wangyebacom\OnLineExamUpdate\Web\SingleSelectAdd.aspx.cs:19
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
改为:string loginName;
if(session["userID"]!=null)
loginName = Session["userID"].ToString();
后对程序的结果有多大影响?
2、源程序TestAnswer.aspx.cx调试出现问题:
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
源错误:
行 29: SqlParameter[] Params1 = new SqlParameter[2];
行 30: DataBase DB = new DataBase();
行 31: int paperID = int.Parse(Session["PaperID"].ToString());
行 32: Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4,paperID); //试卷编号
行 33: Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选");//题目类型
源文件: f:\wangyebacom\OnLineExamUpdate\Web\TestAnswer.aspx.cs 行: 31
堆栈跟踪:
[NullReferenceException: 未将对象引用设置到对象的实例。]
Web_TestAnswer.InitData() in f:\wangyebacom\OnLineExamUpdate\Web\TestAnswer.aspx.cs:31
Web_TestAnswer.Page_Load(Object sender, EventArgs e) in f:\wangyebacom\OnLineExamUpdate\Web\TestAnswer.aspx.cs:23
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
请教老师,这个该如何更改?谢谢!
附包含改源码的部分代码程序如下:
SqlParameter[] Params1 = new SqlParameter[2];
DataBase DB = new DataBase();
int paperID = int.Parse(Session["PaperID"].ToString());
Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号
Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选题"); //题目类型
DataSet ds1 = DB.GetDataSet("Proc_PaperDetail", Params1);
GridView1.DataSource = ds1;
GridView1.DataBind();
((Label)GridView1.HeaderRow.FindControl("Label27")).Text = ((Label)GridView1.Rows[0].FindControl("Label4")).Text;
另外,程序调试是说ds1传送的是空值,郁闷!请不吝赐教