cyimxtck
asked on
C# Properties getting null values back instead of actual values
I am trying to have a form which gets submitted and passes various text box parameters down along the way. So I have properties in class for that with private strings (didn't use the auto-implemented properties but tried both).
Here is where the values originate from a WPF form:
var exe = new DataReadWrite();
var uv = new UserValues();
uv.strFirstName = tbxFirstName.Text;
uv.strLastName = tbxLastName.Text;
uv.strEmailAddress = tbxEmailAddress.Text;
exe.exeInsUser();
In the debugger the values above are populated...
Now when exeInsUser() chokes, it is due to the values being null as here:
separate class to hold the values:
public class UserValues
{
private String firstname;
private String lastname;
private String emailaddress;
public string strFirstName
{
get
{
return firstname;
}
set
{
firstname = value;
}
}
public string strLastName
{
get
{
return lastname;
}
set
{
lastname = value;
}
}
public string strEmailAddress
{
get
{
return emailaddress;
}
set
{
emailaddress = value;
}
}
The execution fails here with a null reference exception:
separate class to execute:
var oPa = new DataParameters();
var str = new UserValues();
StoredProcParameter[] oPL = oPa.insUsersParm( str.strFirstName
, str.strLastName
, str.strEmailAddress);
I even tried implementing an interface (although the code above has this removed in the implementation) but everything is null!?
Any help is greatly appreciated!
Here is where the values originate from a WPF form:
var exe = new DataReadWrite();
var uv = new UserValues();
uv.strFirstName = tbxFirstName.Text;
uv.strLastName = tbxLastName.Text;
uv.strEmailAddress = tbxEmailAddress.Text;
exe.exeInsUser();
In the debugger the values above are populated...
Now when exeInsUser() chokes, it is due to the values being null as here:
separate class to hold the values:
public class UserValues
{
private String firstname;
private String lastname;
private String emailaddress;
public string strFirstName
{
get
{
return firstname;
}
set
{
firstname = value;
}
}
public string strLastName
{
get
{
return lastname;
}
set
{
lastname = value;
}
}
public string strEmailAddress
{
get
{
return emailaddress;
}
set
{
emailaddress = value;
}
}
The execution fails here with a null reference exception:
separate class to execute:
var oPa = new DataParameters();
var str = new UserValues();
StoredProcParameter[] oPL = oPa.insUsersParm( str.strFirstName
, str.strLastName
, str.strEmailAddress);
I even tried implementing an interface (although the code above has this removed in the implementation) but everything is null!?
Any help is greatly appreciated!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
public void exeInsUser()
{
insUsers();
}
{
insUsers();
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect!
ASKER
In the bottom half of the original post:
separate class to execute:
var oPa = new DataParameters();
var str = new UserValues();
StoredProcParameter[] oPL = oPa.insUsersParm( str.strFirstName
, str.strLastName
, str.strEmailAddress);