protected void page load()
{
blick=1;
j=0;
}
protected button1_click()
{
bclick=blick+1;
j=j+1;
ReferenceDetails[]rfobj=new ReferenceDetails[bclick];
if(j<=bclick)
{
rfobj[j]=new ReferenceDetails();
rfobj[j].name=txtrfname.text;
rfobj[j].lastname=txtrflastname.text;
}
}
protected preview button_click()
{
Response.write(rfobj[1].name); // HOW i should achieve this
Response.write(rfobj[2].name);
//object reference is not set to instance of an object
}
I want to create a new object for the same class with same properties but values are different. On Button first click one object want to create with some properties and bind with values according to user enters.
If the button clicked once again then again a new object wants to be created with same properties but different values what user enters at that time and those values want to bind with that corresponding object.
Then I want to get the each newly generated object with their associated values in another button click to show it to on Gridview. But object is generating newly in the above code as rfobj[1], rfobj[2], but when I go to next button and access that values their will be null.
How do I overcome it? Can anyone provide me with a solution for this problem?