Help: object reference is required for the nonstatic field

T

TdJ

No end of reading on the net and I can not get this to compile! The error
message is:

An object reference is required for the nonstatic field, method, or property
'BusinessAreaDataSet.BusinessAreaTableDataTable.FindByBusinessAreaID(int)'

Could someone explain to me what I am missing ... I wish to understand why
this isn't working


public DescListLookup(UserDataSet dataSet)
{
_enabledDisplayList = new ListItemCollection();
_allDisplayList = new ListItemCollection();

BusinessAreaDataSet myBusinessAreaDataSet = new
BusinessAreaDataSet();

foreach(UserDataSet.UserListTableRow row in dataSet.UserListTable)
{

// access the business area details for this user
BusinessAreaDataSet.BusinessAreaTableRow baRow =
BusinessAreaDataSet.

BusinessAreaTableDataTable.FindByBusinessAreaID(row.BusinessAreaID);

// add the business area details to the the list
AddItem(baRow.BusinessAreaName, baRow.BusinessAreaID,
baRow.BusinessAreaEnabledFlag);

}
}



public BusinessAreaTableRow FindByBusinessAreaID(int BusinessAreaID)
{
return ((BusinessAreaTableRow)(this.Rows.Find(new object[]
{BusinessAreaID})));
}
 
M

Miha Markic

Hi,

Instead of

BusinessAreaTableDataTable.FindByBusinessAreaID(row.BusinessAreaID);

it should be

myBusinessAreaDataSet.BusinessAreaTable.FindByBusinessAreaID(row.BusinessAre
aID);

since BusinessAreaTableDataTable is class declaration and not an instance of
it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top