Click here to Skip to main content
15,922,894 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
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;


}
Posted

pls debug the code,
and check that any object is not assigned ,

also verify that null reference for the same.
 
Share this answer
 
Comments
Syed.net 9-Jan-13 1:19am    
I have done debugging, and its showing PreviousLeadFollowUp as null.
pls tell me how to get the value
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.
 
Share this answer
 
Comments
Syed.net 9-Jan-13 1:42am    
Thanks guys ,Solved the error

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900