作为对象引用的错误未设置为对象的实例。 [英] Error as object reference not set to an instance of an object.

查看:71
本文介绍了作为对象引用的错误未设置为对象的实例。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI
请帮助我,下面给出的代码用于编辑按钮(lnkName)但是当我进入4时,选项错误如下所示。在我的应用程序中它是第一个参考集。



protected void lnkName_Click(object sender,EventArgs e)

{

lnkDeleteCurrent.Visible = true;

ddlProduct.ClearSelection();

ddlLead.ClearSelection();

ddlEmployee.ClearSelection();

ddlStatus .ClearSelection();

var hdnId =(HiddenField)((LinkBut​​ton)sender).Parent.FindControl(hdnId);

var leadFollowUp = new LeadFollowUpManager() .GetLeadFollowUpById(hdnId.Value.ToGuid());



hdnCurrentId.Value = leadFollowUp.Id.ToString();



LeadFollowUp previousLeadFollowUp = new LeadFollowUpManager()。GetLeadFollowUpsByNextFollowUpReferenceId(leadFollowUp.Id).Where(parentLeadFollowUp => parentLeadFollowUp.NextFollowUpStatusId == 2).FirstOrDefault();



ddlProduct.Items.FindByValue(previousLeadFollowUp.Lead.Product.Id.ToString())。Selected = true; // ERROR :对象参考未设置为对象的实例。

BindLeadByProduct(previousLeadFollowUp.Lead.Product.Id);

ddlLead.Items.FindByValue(previousLeadFollowUp.LeadId.ToString ())。Selected = true;

ddlEmployee.Items.FindByValue(previousLeadFollowUp.EmployeeId.ToString())。Selected = true;

ddlStatus.Items.FindByValue(previousLeadFollowUp .NextFollowUpStatusId.ToString())。Selected = true;

BindParentFollowUpReference();

ddlFolloeUpReference.Items.FindByValue(previousLeadFollowUp.Id.ToString())。Selected = true ;



if(string.IsNullOrEmpty(previousLeadFollowUp.Date.ToString()))

txtDate.Text =;

else

txtDate.Text = previousLeadFollowUp.Date.Value.ToString(dd / MMM / yyyy);



if(string.IsNullOrEmpty(previousLeadFollowUp.Time))

txtTime.Text = ;

其他

txtTime.Text = previousLeadFollowUp.Time.ToString();



if( string.IsNullOrEmpty(previousLeadFollowUp.ContactPerson))

txtContactPerson.Text =;

else

txtContactPerson.Text = previousLeadFollowUp.ContactPerson;



if(string.IsNullOrEmpty(previousLeadFollowUp.FollowUpDetail))

txtFollowUpDetail.Text =;

else

txtFollowUpDetail.Text = previousLeadFollowUp.FollowUpDetail;





if(string.IsNullOrEmpty(leadFollowUp.NextFollowUpDate。 ToString()))

txtNextFollowUpDate.Text =;

else

txtNextFollowUpDate.Text = leadFollowUp.NextFollowUpDate.Value.ToString( dd / MMM / yyyy);



if(string.IsNullOrEmpty(leadFollowUp.NextFollowUpTime))

txtNextFollowUpTime.Text =;

else

txtNextFollowUpTime.Text = leadFollowUp.NextFollowUpTime.ToString();



if(string.IsNullOrEmpty(leadFollowUp.NextFollowUpPerson))

txtNextFollowUpContactPerson.Text =;

else

txtNextFollowUpContactPerson.Text = leadFollowUp.NextFollowUpPerson;



if(string.IsNullOrEmpty(leadFollowUp.NextFollowUpDetail))

txtNextFollowUpDetail.Text = ;

其他

txtNextFollowUpDetail.Text = leadFollowUp.NextFollowUpDetail;





}

HI pls help me out , the below given code is for edit button (lnkName) but when i m going 4 the option error is shown as stated below.In my application its the first reference set.

protected void lnkName_Click(object sender, EventArgs e)
{
lnkDeleteCurrent.Visible = true;
ddlProduct.ClearSelection();
ddlLead.ClearSelection();
ddlEmployee.ClearSelection();
ddlStatus.ClearSelection();
var hdnId = (HiddenField)((LinkButton)sender).Parent.FindControl("hdnId");
var leadFollowUp = new LeadFollowUpManager().GetLeadFollowUpById(hdnId.Value.ToGuid());

hdnCurrentId.Value = leadFollowUp.Id.ToString();

LeadFollowUp previousLeadFollowUp = new LeadFollowUpManager().GetLeadFollowUpsByNextFollowUpReferenceId(leadFollowUp.Id).Where(parentLeadFollowUp => parentLeadFollowUp.NextFollowUpStatusId == 2).FirstOrDefault();

ddlProduct.Items.FindByValue(previousLeadFollowUp.Lead.Product.Id.ToString()).Selected = true;//ERROR:OBJECT REFERENCE NOT SET TO AN INSTANCE OF AN OBJECT.
BindLeadByProduct(previousLeadFollowUp.Lead.Product.Id);
ddlLead.Items.FindByValue(previousLeadFollowUp.LeadId.ToString()).Selected = true;
ddlEmployee.Items.FindByValue(previousLeadFollowUp.EmployeeId.ToString()).Selected = true;
ddlStatus.Items.FindByValue(previousLeadFollowUp.NextFollowUpStatusId.ToString()).Selected = true;
BindParentFollowUpReference();
ddlFolloeUpReference.Items.FindByValue(previousLeadFollowUp.Id.ToString()).Selected = true;

if (string.IsNullOrEmpty(previousLeadFollowUp.Date.ToString()))
txtDate.Text = "";
else
txtDate.Text = previousLeadFollowUp.Date.Value.ToString("dd/MMM/yyyy");

if (string.IsNullOrEmpty(previousLeadFollowUp.Time))
txtTime.Text = "";
else
txtTime.Text = previousLeadFollowUp.Time.ToString();

if (string.IsNullOrEmpty(previousLeadFollowUp.ContactPerson))
txtContactPerson.Text = "";
else
txtContactPerson.Text = previousLeadFollowUp.ContactPerson;

if (string.IsNullOrEmpty(previousLeadFollowUp.FollowUpDetail))
txtFollowUpDetail.Text = "";
else
txtFollowUpDetail.Text = previousLeadFollowUp.FollowUpDetail;


if (string.IsNullOrEmpty(leadFollowUp.NextFollowUpDate.ToString()))
txtNextFollowUpDate.Text = "";
else
txtNextFollowUpDate.Text = leadFollowUp.NextFollowUpDate.Value.ToString("dd/MMM/yyyy");

if (string.IsNullOrEmpty(leadFollowUp.NextFollowUpTime))
txtNextFollowUpTime.Text = "";
else
txtNextFollowUpTime.Text = leadFollowUp.NextFollowUpTime.ToString();

if (string.IsNullOrEmpty(leadFollowUp.NextFollowUpPerson))
txtNextFollowUpContactPerson.Text = "";
else
txtNextFollowUpContactPerson.Text = leadFollowUp.NextFollowUpPerson;

if (string.IsNullOrEmpty(leadFollowUp.NextFollowUpDetail))
txtNextFollowUpDetail.Text = "";
else
txtNextFollowUpDetail.Text = leadFollowUp.NextFollowUpDetail;


}

推荐答案

请调试代码,

并检查是否未分配任何对象,



也验证相同的空引用。
pls debug the code,
and check that any object is not assigned ,

also verify that null reference for the same.






在y中放置一个中断我们的逻辑检查一行一行,它显示错误

你检查它。



那个错误导致没有无论你的搜索和参数都不匹配的数据...



所以,我的建议是请使用断点检查。
Hi,

Put a Break in your logic check line by line in which line it''s showing that error
you check it.

That error causes there is no data in whatever your searching and parameters are missmatching ...

So, my advise is please check using break point.


这篇关于作为对象引用的错误未设置为对象的实例。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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