Hi tere, I have a seperate class called Author:
using System;
namespace DocumentControl
{
/// <summary>
/// Summary description for Author.
/// </summary>
public class Author
{
private string strReport = "";
private string strIssue = "";
private string strAuthors = "";
public Author(string strReport, string strIssue, string strAuthors)
{
this.strReport = strReport;
this.strIssue = strIssue;
this.strAuthors = strAuthors;
}
public string StrReports
{
set
{
strReport = value;
}
get
{
return strReport;
}
}
public string StrIssue
{
set
{
strIssue = value;
}
get
{
return strIssue;
}
}
public string StrAuthor
{
set
{
strAuthors = value;
}
get
{
return strAuthors;
}
}
}
}
I declare the object in the parent class:
private Author objAuthor = null;
I create the object on a Button Event whcih works fine and the values are in
the object.
private void AddAuthor(objec t source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
objAuthor = new Author(e.Item.C ells[2].Text, e.Item.Cells[6].Text,
e.Item.Cells[12].Text);
}
Now I try to access the object from a different Button Click event:
private void ButtonAddAuthor _Click(object sender, System.EventArg s e)
{
TextBox3.Text = objAuthor.StrRe ports;
TextBox4.Text = objAuthor.StrIs sue;
TextBox5.Text = objAuthor.StrAu thor;
}
But I get the error: Object reference not set to an instance of an object
Why can't I access the objects content? What is wrong? Thanks a lot for any
feedback
Chris
using System;
namespace DocumentControl
{
/// <summary>
/// Summary description for Author.
/// </summary>
public class Author
{
private string strReport = "";
private string strIssue = "";
private string strAuthors = "";
public Author(string strReport, string strIssue, string strAuthors)
{
this.strReport = strReport;
this.strIssue = strIssue;
this.strAuthors = strAuthors;
}
public string StrReports
{
set
{
strReport = value;
}
get
{
return strReport;
}
}
public string StrIssue
{
set
{
strIssue = value;
}
get
{
return strIssue;
}
}
public string StrAuthor
{
set
{
strAuthors = value;
}
get
{
return strAuthors;
}
}
}
}
I declare the object in the parent class:
private Author objAuthor = null;
I create the object on a Button Event whcih works fine and the values are in
the object.
private void AddAuthor(objec t source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
objAuthor = new Author(e.Item.C ells[2].Text, e.Item.Cells[6].Text,
e.Item.Cells[12].Text);
}
Now I try to access the object from a different Button Click event:
private void ButtonAddAuthor _Click(object sender, System.EventArg s e)
{
TextBox3.Text = objAuthor.StrRe ports;
TextBox4.Text = objAuthor.StrIs sue;
TextBox5.Text = objAuthor.StrAu thor;
}
But I get the error: Object reference not set to an instance of an object
Why can't I access the objects content? What is wrong? Thanks a lot for any
feedback
Chris
Comment