数据第二次在page_load上获取错误... [英] data fetch second time on page_load giving error....

查看:114
本文介绍了数据第二次在page_load上获取错误...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第二次在page_load上获取数据导致错误....
表示第一次从其他页面获取数据时的第一次正确获取.
代码是:-公共局部类UpdatePage:System.Web.UI.Page
{

字符串sEcode =";
字符串semployeename =";
字符串sdepartment =";
字符串slocation =";
字符串sdeptcode =";
受保护的void Page_Load(对象发送者,EventArgs e)
{

库lib = new Library();
sEcode = Request.QueryString ["cc"].ToString();
semployeename = Request.QueryString ["cd"].ToString();
sdepartment = Request.QueryString ["ce"].ToString();
slocation = Request.QueryString ["cf"].ToString();


txtempcode.Text = sEcode;
txtEmployeename.Text =雇员姓名;
txtdepartment.Text = sdepartment;
txtlocation.Text = slocation;



}
但是在第二次从其他页面获取数据时,它给出了错误
像:-
公共局部类UpdatePage:System.Web.UI.Page
{

字符串sEcode =";
字符串semployeename =";
字符串sdepartment =";
字符串slocation =";
字符串sdeptcode =";
受保护的void Page_Load(对象发送者,EventArgs e)
{

库lib = new Library();
sEcode = Request.QueryString ["cc"].ToString();
semployeename = Request.QueryString ["cd"].ToString();
sdepartment = Request.QueryString ["ce"].ToString();
slocation = Request.QueryString ["cf"].ToString();


txtempcode.Text = sEcode;
txtEmployeename.Text =雇员姓名;
txtdepartment.Text = sdepartment;
txtlocation.Text = slocation;

下面两行第二次读取数据.
我可以在以下两行中写以下内容:
还是我不得不做别的事情.

错误消息是:-对象引用未设置为对象的实例.
sdeptcode = Request.QueryString ["co"].ToString();
txtDeptcode.Text = sdeptcode;
}


请有人帮我第二次重载时如何编写以获取数据....

data fetch second time on page_load giving error....
means first time when i am fetching data from other page its properly fetched.
code is:-public partial class UpdatePage : System.Web.UI.Page
{

string sEcode = "";
string semployeename = "";
string sdepartment = "";
string slocation = "";
string sdeptcode = "";
protected void Page_Load(object sender, EventArgs e)
{

Library lib = new Library();
sEcode = Request.QueryString["cc"].ToString();
semployeename = Request.QueryString["cd"].ToString();
sdepartment = Request.QueryString["ce"].ToString();
slocation = Request.QueryString["cf"].ToString();


txtempcode.Text = sEcode;
txtEmployeename.Text = semployeename;
txtdepartment.Text = sdepartment;
txtlocation.Text = slocation;



}
but while second time fetching data from other page its giving error
like :-
public partial class UpdatePage : System.Web.UI.Page
{

string sEcode = "";
string semployeename = "";
string sdepartment = "";
string slocation = "";
string sdeptcode = "";
protected void Page_Load(object sender, EventArgs e)
{

Library lib = new Library();
sEcode = Request.QueryString["cc"].ToString();
semployeename = Request.QueryString["cd"].ToString();
sdepartment = Request.QueryString["ce"].ToString();
slocation = Request.QueryString["cf"].ToString();


txtempcode.Text = sEcode;
txtEmployeename.Text = semployeename;
txtdepartment.Text = sdepartment;
txtlocation.Text = slocation;

below two line fetching data second time.
Below two lines shall i can write in this block
or i have to some thing else.

error msg is :-Object reference not set to an instance of an object.
sdeptcode = Request.QueryString["co"].ToString();
txtDeptcode.Text = sdeptcode;
}


please someone help me how to write for fetching data while reload second time....

推荐答案

为什么需要重载?刷新时查询字符串是否仍然存在?您是否认为告诉我们错误消息和错误行可能有助于我们告诉您什么地方出了错?
Why do you need to reload it at all ? Is your query string still present when you refresh ? Did you consider that telling us the error message and line of the error might help us tell you what is wrong ?


这篇关于数据第二次在page_load上获取错误...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆