|
-
Oct 4th, 2006, 10:18 AM
#1
Thread Starter
Fanatic Member
But I get error: Object reference not set to an instyance of an object.
When I define my class like:
public class ProductEntity
{
private int productID;
// Public properties, to expose the state of the entity
public int ProductID
{
get { return productID; }
set { productID = value; }
}
......
then to bind the ProductID to my textbox.Text in a form I do:
textBox1.DataBindings.Add("Text", myProductObject, "ProductID");
But I get error: Object reference not set to an instyance of an object.
But When I initialize the value of productID like in
private int productID=0;
that fixes the problem
My question:
I don t see why I should initialize that value.
Is there a way not to get the error without initializing productID .
and what s a good practice for this pls (I mean binding Business entity classes to form controls)
Thanks
P.S: this is C# but VB.Net is practically the same syntax.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|