Thanks a lot Angel. It worked(But next problem)
Textbox[] txbox = new Textbox [totalRows];
for(int i=0; i < totalRows; i++){
txbox[i] = new Textbox();
txbox[i].ID = "myTextbox"+i;
}
I used above code in my page_load event. It worked. But once all dynamic
empty textboxes got created I entered values in them. Now I want to capture
those values using dynamic IDs of textboxes but those IDs no longer available
after page_load event. I would like to capture all values from textboxes to
INSERT data in SQL table.
"Angelos Karantzalis" wrote:
When you create an array of objects, the objects inside it are NOT
initialized ! In other owrd, it's an array of null values mate ... change
your code to this:
Textbox[] txbox = new Textbox [totalRows];
for(int i=0; i < totalRows; i++){
txbox[i] = new Textbox();
txbox[i].ID = "myTextbox"+i;
}
Angel
O:]
"Bhavin" <Bh****@discussions.microsoft.com> wrote in message
news:15**********************************@microsof t.com... Anybody quickly replies it, would be a great help!
I try to create dynamic array of textboxes control in ASP.NET(C#). I got
the following error while I tried to assign value to ID property of
dynamically created textbox. (look at my code please )
Error: " Object reference is not set to an instance of Object"
totalRows - int variable which varies with number of records in SQL table
Textbox[]txbox = new Textbox [totalRows];
For (int i=0; i < totalRows; i++)
{
txbox[i].ID = "myTextbox"; //Getting error here
}
Thanks,