注册 登录
编程论坛 ASP.NET技术论坛

[求助]怎么解决"未将对象引用设置到对象的实例"的问题啊

海之韵韵 发布于 2007-03-13 11:11, 841 次点击

以下程序运行时老是出错,说是"未将对象引用设置到对象的实例",能帮我看看吗?
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Laga.Accounts;

namespace Laga.Web.Modules.Dfkphb
{
/// <summary>
/// Cjlr 的摘要说明。
/// </summary>
public class Cjlr : LagaWebPage
{
protected System.Web.UI.WebControls.Repeater Dfkmx;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Label Title;

private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
if(!Permission.HasPermission(Context.User.Identity.Name,20200010))
{
Server.Transfer("/Modules/Users/Err.htm",true);
}
Title.Text = Request["Dw"] + Request["Sj"].Substring(0,4) + "年" + Request["Sj"].Substring(5,2) + "月打防控排行榜成绩明细";
Laga.JcxxPhb.Dfkphb objDfk = new Laga.JcxxPhb.Dfkphb();
Dfkmx.DataSource = objDfk.GetMx(Request["Dwbh"],Request["Sj"],Context.User.Identity.Name,Request.UserHostAddress).Tables[0];
Dfkmx.DataBind();
Button2.Attributes.Add("onclick","window.location.href='Cjgl.aspx?Dwxl=" + Request["Dwxl"] + "&Sj=" + Request["Sj"] + "&Order=" + Request["Order"] + "';");
}
}

protected string GetXm(string xm,string xmid)
{
string xmtd;
if(ViewState["xmid"] == null)
{
Laga.JcxxPhb.Dfkphb objDfk = new Laga.JcxxPhb.Dfkphb();
string sl = objDfk.Xmsl(int.Parse(xmid));
xmtd = "<td rowspan='" + sl + "' align='center'>" + xm + "</td>";
}
else
{
if(ViewState["xmid"].ToString() != xmid)
{
Laga.JcxxPhb.Dfkphb objDfk = new Laga.JcxxPhb.Dfkphb();
string sl = objDfk.Xmsl(int.Parse(xmid));
xmtd = "<td rowspan='" + sl + "' align='center'>" + xm + "</td>";
}
else
{
xmtd = "";
}
}
ViewState["xmid"] = xmid;
return xmtd;
}


#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void Button1_Click(object sender, System.EventArgs e)
{
Laga.JcxxPhb.Dfkphb objDfk = new Laga.JcxxPhb.Dfkphb();
int id;
decimal fs;
string mx;
foreach(RepeaterItem a in Dfkmx.Items)
{
id = int.Parse(((Label)a.FindControl("ID")).Text);
try
{
fs = decimal.Parse(((TextBox)a.FindControl("Fs")).Text);
}
catch
{
fs = 0;
}
mx = ((TextBox)a.FindControl("Mx")).Text;
objDfk.UpdateMx(id,fs,mx);
}
objDfk.Tj(int.Parse(Request["Dwxl"]),Request["Sj"]);
Page.RegisterStartupScript("saveok","<script>if ( confirm('成绩保存成功\\n返回排行榜吗?') ) window.location.href='Cjgl.aspx?Dwxl=" + Request["Dwxl"] + "&Sj=" + Request["Sj"] + "&Order=" + Request["Order"] + "';else window.location.href='Cjlr.aspx?Dwbh=" + Request["Dwbh"] + "&Dw=" + Request["Dw"] + "&Dwxl=" + Request["Dwxl"] + "&Sj=" + Request["Sj"] + "&Order=" + Request["Order"] + "';</script>");
}
}
}

3 回复
#2
cyyu_ryh2007-03-13 12:12
操作哪一步是显示的未将对象引用设置到对象的实例
#3
冰镇柠檬汁儿2007-03-13 13:20
楼主,把错误的代码标出来
#4
海之韵韵2007-03-14 13:53
回复:(冰镇柠檬汁儿)楼主,把错误的代码标出来

这是一个后台程序,在一个后台的平台上链接它提示出这样的错误码,整个程序我也找不到哪里是错误的代码!您能抽点时间帮我看看吗?

1