DVBBS ASP.NET论坛官方 注册  |   登录  |   搜索  |  帮助
DVBBS ASP.NET论坛官方  →  技术交流区  →  .Net技术讨论  →  [求助]请高手来帮忙看看是怎么回事(在线等待)
共有 375 人关注过本帖
上一主题 | 下一主题  

[求助]请高手来帮忙看看是怎么回事(在线等待)

我正在线哦! 管你啥事 积分:13 等级:新手上路 文章:2 积分:13 注册:2008年3月29日 威望:1 点   楼主 个性首页 QQ 邮箱 主页 发短信 加为好友

“/”应用程序中的服务器错误。

未将对象引用设置到对象的实例。

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

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

源错误:

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。

[NullReferenceException: 未将对象引用设置到对象的实例。]
   MagicAjax.AjaxCallHelper.GetPageHiddenDictionary(Page page, String fieldName) +34
   MagicAjax.AjaxCallHelper.Page_PreRender(Object sender, EventArgs e) +245
   System.Web.UI.Control.OnPreRender(EventArgs e) +2117788
   System.Web.UI.Control.PreRenderRecursiveInternal() +86
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041

版本信息: Microsoft .NET Framework 版本:2.0.50727.1433; ASP.NET 版本:2.0.50727.1433

CS源文:

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 System.IO;
using System.Data.OleDb;
namespace mzg
{
 /// <summary>
 /// data_show 的摘要说明。
 /// </summary>
 public class data_show : System.Web.UI.Page
 {
  int pageSize,recordCount,pageCount,currentPage;
  protected System.Web.UI.WebControls.DataList dl_show;
  protected System.Web.UI.HtmlControls.HtmlForm Form1;
  protected System.Web.UI.WebControls.Repeater rp_count;
  protected string webname;
  protected string description;
  protected string keywords;
  protected DbSql sql=new DbSql();
  protected Common cn=new Common();
  protected System.Web.UI.WebControls.DropDownList dlsPageIndex;
  protected System.Web.UI.WebControls.LinkButton butPrev;
  protected System.Web.UI.WebControls.LinkButton btnNext;
  protected MagicAjax.UI.Controls.AjaxPanel Panel;
  protected MagicAjax.UI.Controls.AjaxPanel Panel2;
  protected DataSet ds=new DataSet();
  //protected mzg.control.page page=new mzg.control.page();
  private void Page_Load(object sender, System.EventArgs e)
  {
   pageSize=9;
   if(!Page.IsPostBack)
   {
    page();
    showcount();
    web();
    BindData();
   }
  }
  private void web()
  {
   try
   {
    ds=sql.RunSql_DataSet("select webname,M_keywords,M_description from lacus_system where id=1");
    webname=ds.Tables[0].Rows[0]["webname"].ToString();
    description=ds.Tables[0].Rows[0]["M_description"].ToString();
    keywords=ds.Tables[0].Rows[0]["M_keywords"].ToString();
   }
   catch
   {
    Response.Redirect("500.html");
   }
  }
  private void showcount()
  {
   try
   {
    ds=sql.RunSql_DataSet("select top 10 tvname,tvcount,id from tvindexs order by tvcount desc");
    this.rp_count.DataSource=ds;
    this.rp_count.DataBind();
   }
   catch
   {
    Response.Redirect("500.html");
   }
  }
  public void BindData()
  {
   try
   {
    int startPage;
    startPage = currentPage * pageSize;
 
    OleDbParameter[] parameter={new OleDbParameter("@id",OleDbType.Integer,5)};
    parameter[0].Value=cn.NoHTML(cn.ReplaceBadChar(Request.QueryString["id"]));
    ds=sql.RunSql_DataSet(parameter,"select id,idd,pname,pimage,psex,pheight,page,pxue,psy,psanwei,pbrithday,ptizhong,pxingzuo,pborn,plikething,plinkpeople,pmouth,punlike,pmiaoshu,pmiaoshu,inlikepeople,inlikething,inmouth,inunlike from tvpage where idd=@id",startPage,pageSize);
    dl_show.DataSource = ds;
    dl_show.DataBind();
    dlsPageIndex.SelectedIndex = currentPage;
   // page.Allpage=3;
   // page.Pagecount=2;
   // page.Pagesize=5; 
   }
   catch
   {
    Response.Redirect("500.html");
   }
  }
  #region Web 窗体设计器生成的代码
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {   
   this.butPrev.Click += new System.EventHandler(this.butPrev_Click);
   this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
   this.dlsPageIndex.SelectedIndexChanged += new System.EventHandler(this.dlsPageIndex_SelectedIndexChanged);
   this.Load += new System.EventHandler(this.Page_Load);

  }
  #endregion

  //各种验证是否为空
  public string c_age(object age)
  {
   if(age.ToString()!="0")
   {
    return "年龄:"+age+"<br />";
   }
   else
   {
    return null;
   }
  }
  //声优
  public string c_sy(object sy)
  {
   if(sy.ToString()!="null")
   {
    return "声优:"+sy+"<br />";
   }
   else
   {
    return null;
   }
  }
  //身高
  public string c_height(object height)
  {
   if(height.ToString()!="0")
   {
    return "身高:"+height+"<br />";
   }
   else
   {
    return null;
   }
  }
  //三围
  public string c_sanwei(object sanwei)
  {
   if(sanwei.ToString()!="0")
   {
    return "三围:"+sanwei+"<br />";
   }
   else
   {
    return null;
   }
  }
  //星座
  public string c_xingzuo(object xingzuo)
  {
   if(xingzuo.ToString()!="null")
   {
    return "星座:"+xingzuo+"<br />";
   }
   else
   {
    return null;
   }
  }
  //体重
  public string c_tizhong(object tizhong)
  {
   if(tizhong.ToString()!="0")
   {
    return "体重:"+tizhong+"<br />";
   }
   else
   {
    return null;
   }
  }
  //生日
  public string c_brithday(object brithday)
  {
   if(brithday.ToString()!="0")
   {
    return "生日:"+brithday+"<br />";
   }
   else
   {
    return null;
   }
  }
  //血型
  public string c_xue(object xue)
  {
   if(xue.ToString()!="null")
   {
    return "血型:"+xue+"<br />";
   }
   else
   {
    return null;
   }
  }
  //出生地
  public string c_born(object born)
  {
   if(born.ToString()!="null")
   {
    return "出生地:"+born+"<br />";
   }
   else
   {
    return null;
   }
  }
  //喜欢的东西
  public string c_like(object inlike,object plike)
  {
   if(plike.ToString()!="null" )
   {
    return inlike+":"+plike+"<br />";
   }
   else
   {
    return null;
   }
  }
  //不喜欢的东西
 
  public string c_unlike(object inunlike,object punlike)
  {
   if(punlike.ToString()!="null" )
   {
    return inunlike+":"+punlike+"<br />";
   }
   else
   {
    return null;
   }
  }
  //口头禅
 
  public string c_mouth(object inmouth,object pmouth)
  {
   if(pmouth.ToString()!="null" )
   {
    return inmouth+":"+pmouth;
   }
   else
   {
    return null;
   }
  }
  //描述
  public string c_jianjie(object jianjie)
  {
   if(jianjie.ToString()!="")
   {
    return "简介:"+jianjie;
   }
   else
   {
    return null;
   }
  }
  //头像
  public string c_head(object head)
  {
   if(head.ToString()!="null" &&  File.Exists(Server.MapPath(".")+"/head/"+head))
   {
   //return Server.MapPath(".")+"/head/"+head;
   return "<IMG   src=head/"+head+" width=''96'' height=''121'' >";
   }
   else
   {
    return "<IMG   src=head/null.gif>";
   }
  }

  private void butPrev_Click(object sender, System.EventArgs e)
  {
   currentPage = (int)ViewState["CurrentPage"];
   pageCount = (int)ViewState["PageCount"];
   recordCount = (int)ViewState["RecordCount"];
   if(currentPage>0)
    currentPage--;
   ViewState["CurrentPage"] = currentPage;
   BindData();
  }

  private void btnNext_Click(object sender, System.EventArgs e)
  {
   currentPage = (int)ViewState["CurrentPage"];
   pageCount = (int)ViewState["PageCount"];
   recordCount = (int)ViewState["RecordCount"];
   if(currentPage<pageCount)
    currentPage++;
   ViewState["CurrentPage"] = currentPage;
   BindData();
  }

  private void dlsPageIndex_SelectedIndexChanged(object sender, System.EventArgs e)
  {
   currentPage = (int)ViewState["CurrentPage"];
   pageCount = (int)ViewState["PageCount"];
   recordCount = (int)ViewState["RecordCount"];
   currentPage = int.Parse(dlsPageIndex.SelectedItem.Value);
   ViewState["CurrentPage"] = currentPage;
   BindData();
  }
  private void page()
  {
   string id=cn.NoHTML(cn.ReplaceBadChar(Request.QueryString["id"]));
   if(!cn.IsNumeric(id))
   {
    Response.Redirect("500.html");
   }
   OleDbParameter[] parameter={new OleDbParameter("@id",OleDbType.Integer,5)};
   parameter[0].Value=id;
   currentPage = 0; // 初始化当前页为第0页
   ViewState["CurrentPage"] = 0;
   recordCount = sql.counts(parameter," Select count(*) as Total from tvpage where idd=@id"); // 计算共有多少条记录
   ViewState["RecordCount"] = recordCount;

   pageCount = recordCount / pageSize; // 计算共有多少页
   ViewState["PageCount"] = pageCount;

   for(int i=1;i<=(pageCount+1);i++)
   {
    dlsPageIndex.Items.Add(new ListItem("第"+i+"页",(i-1).ToString()));
   }
  }
 }
}



2008-4-22 21:31:46   举报   Top
我正在线哦! 管你啥事 积分:13 等级:新手上路 文章:2 积分:13 注册:2008年3月29日 威望:1 点   沙发 个性首页 QQ 邮箱 主页 发短信 加为好友

自己顶一把,谁能帮忙看看..???

2008-4-28 17:14:40   举报   Top
我不在线哦! 冷月啸 积分:15 等级:新手上路 文章:5 积分:15 注册:2008年5月22日 威望:0 点   板凳 个性首页 QQ 邮箱 主页 发短信 加为好友
看提示大概问题是 一个类或一个对象没有实例化 你可以调试下
2008-5-22 9:52:06   举报   Top
1  3 | 10    1/1 页